using Contracts.SearchModels; using Contracts.ViewModels; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; namespace WebApp.Pages { [AllowAnonymous] public class IndexModel : PageModel { public List ProductsModel { get; set; } public Dictionary> MediaByProductsModel { get; set; } public void OnGet(double? pricefrom, double? priceto, string? search) { string request = "Product/GetList"; if (!string.IsNullOrEmpty(search)) request += $"?search={search}"; if (pricefrom != null) request += $"?pricefrom={pricefrom}"; if (priceto != null) request += $"?priceto={priceto}"; ProductsModel = APIClient.GetRequest>(request); MediaByProductsModel = APIClient.GetRequest>>($"MediaFile/GetByProducts?"); } public byte[] GetMediaByProduct(ProductViewModel productModel) { MediaByProductsModel.TryGetValue(productModel.Id, out List models); return models[0].Image; } } }