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 15:50:56 +04:00
|
|
|
public Dictionary<ProductViewModel, List<MediaFileViewModel>> MediaByProductsModel { get; set; }
|
2024-05-09 17:45:03 +04:00
|
|
|
|
|
|
|
public void OnGet()
|
|
|
|
{
|
2024-06-25 15:50:56 +04:00
|
|
|
ProductsModel = APIClient.GetRequest<List<ProductViewModel>>($"Product/GetFullList");
|
|
|
|
MediaByProductsModel = APIClient.GetRequest<Dictionary<ProductViewModel, List<MediaFileViewModel>>>($"MediaFile/GetByProducts?");
|
|
|
|
}
|
|
|
|
public List<MediaFileViewModel> GetMediaByProduct(ProductViewModel productModel)
|
|
|
|
{
|
|
|
|
MediaByProductsModel.TryGetValue(productModel, out List<MediaFileViewModel> models);
|
|
|
|
return models;
|
2024-05-09 17:45:03 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|