2024-06-25 20:26:34 +04:00
|
|
|
using Contracts.SearchModels;
|
2024-06-25 15:03:16 +04:00
|
|
|
using Contracts.ViewModels;
|
|
|
|
using Microsoft.AspNetCore.Authorization;
|
2024-05-09 17:45:03 +04:00
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
using Microsoft.AspNetCore.Mvc.RazorPages;
|
|
|
|
|
|
|
|
namespace WebApp.Pages
|
|
|
|
{
|
2024-06-25 15:03:16 +04:00
|
|
|
[AllowAnonymous]
|
2024-05-09 17:45:03 +04:00
|
|
|
public class IndexModel : PageModel
|
|
|
|
{
|
2024-06-25 15:03:16 +04:00
|
|
|
public List<ProductViewModel> ProductsModel { get; set; }
|
2024-06-25 20:26:34 +04:00
|
|
|
public Dictionary<Guid, List<MediaFileViewModel>> MediaByProductsModel { get; set; }
|
2024-05-09 17:45:03 +04:00
|
|
|
|
2024-06-25 20:26:34 +04:00
|
|
|
public void OnGet(double? pricefrom, double? priceto, string? search)
|
2024-05-09 17:45:03 +04:00
|
|
|
{
|
2024-06-25 20:26:34 +04:00
|
|
|
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<List<ProductViewModel>>(request);
|
2024-06-26 08:04:07 +04:00
|
|
|
MediaByProductsModel = APIClient.GetRequest<Dictionary<Guid, List<MediaFileViewModel>>>($"MediaFile/GetByProducts");
|
2024-06-25 15:50:56 +04:00
|
|
|
}
|
2024-06-25 20:26:34 +04:00
|
|
|
public byte[] GetMediaByProduct(ProductViewModel productModel)
|
2024-06-25 15:50:56 +04:00
|
|
|
{
|
2024-06-25 20:26:34 +04:00
|
|
|
MediaByProductsModel.TryGetValue(productModel.Id, out List<MediaFileViewModel> models);
|
|
|
|
return models[0].Image;
|
2024-05-09 17:45:03 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|