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 List SalesModel { get; set; } public Dictionary> MediaByProductsModel { get; set; } public void OnGet(double? pricefrom, double? priceto, string? search, string? category) { string request = "Product/GetList"; if (!string.IsNullOrEmpty(search)) request += $"?search={search}&"; if (!string.IsNullOrEmpty(category)) request += $"?category={category}&"; if (pricefrom != null) request += $"?pricefrom={pricefrom}&"; if (priceto != null) request += $"?priceto={priceto}"; ProductsModel = APIClient.GetRequest>(request); MediaByProductsModel = APIClient.GetRequest>>($"MediaFile/GetByProducts"); SalesModel = APIClient.GetRequest>($"Sale/GetList"); } public byte[] GetMediaByProduct(ProductViewModel productModel) { MediaByProductsModel.TryGetValue(productModel.Id, out List models); return models[0].Image; } } }