This is my first question on stackoverflow, so please excuse me if title or question is not good.
At the moment I got VoucherResponse class
public class VoucherResponse
{
public int VoucherID { get; set; }
public string VoucherTitle { get; set; }
public IEnumerable<VoucherVariant> VoucherVariants { get; set; }
public string[] VoucherImages { get; set; }
}
And Web api method
return Ok(from v in distinctby
select new VoucherResponse
{
VoucherID = v.VoucherID,
VoucherTitle = v.VoucherTitle,
VoucherVariants = (from voucher in voucherToLookup[v.VoucherID]
select new VoucherVariant
{
VoucherDiscountedPrice = voucher.VoucherPrice - (voucher.VoucherPrice * voucher.VoucherDiscount/ 100),
VoucherVariantId = voucher.VoucherVariantId,
VoucherPrice = voucher.VoucherPrice,
VoucherStock = 1
}),
VoucherImages = (from image in distinctby
where v.VoucherID == image.VoucherID
select image.VoucherImages
// URLHelper.GetAbsoluteUrl(ModuleCommands.MediaLibraryGetMediaFileUrl(image.FileGUID, voucher.NodeAlias + "_" + image.ImageOrder))).ToArray(),
).ToArray()
});
At the moment I am getting results
{
"voucherID": 380,
"voucherTitle": "Woolworths e-Gift Card",
"voucherVariants": [
{
"voucherVariantId": 397,
"voucherPrice": 100,
"voucherDiscountedPrice": 95,
"voucherStock": 1
},
{
"voucherVariantId": 389,
"voucherPrice": 200,
"voucherDiscountedPrice": 190,
"voucherStock": 1
},
{
"voucherVariantId": 393,
"voucherPrice": 300,
"voucherDiscountedPrice": 285,
"voucherStock": 1
},
{
"voucherVariantId": 394,
"voucherPrice": 400,
"voucherDiscountedPrice": 380,
"voucherStock": 1
},
{
"voucherVariantId": 395,
"voucherPrice": 500,
"voucherDiscountedPrice": 475,
"voucherStock": 1
}
],
"voucherImages": [
" B4A3A070-3ED1-4086-8B33-21465AA58C7A, 2FB01963-2D71-4C79-9EE8-38A114CAF1A6"
]
I need to return voucherImages like this
"VoucherImages" : [
{"www.kentico.info/imageOne.jpg"}
{"www.kentico.info/imageTwo.jpg"}
]
First of all thanks for trying to help me. I resolved this problem by myself. @rocky images are stored in media library, I created method that seams to be working but I still getting "ugly url" like "http://localhost:50848/getmedia/8f5f2e87-782c-4ee2-b6c0-dba614588fe4/ I would like to get something like "http://localhost:50848/getmedia/image1.jpg But will do research on this, if anyone need the code in the feature i will paste method below