PIAPS_CW/WebApp/Pages/Index.cshtml.cs

26 lines
939 B
C#
Raw Normal View History

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; }
public Dictionary<ProductViewModel, List<MediaFileViewModel>> MediaByProductsModel { get; set; }
2024-05-09 17:45:03 +04:00
public void OnGet()
{
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
}
}
}