PIAPS_CW/WebApp/Pages/Cart.cshtml.cs

35 lines
1.1 KiB
C#
Raw Normal View History

2024-06-26 08:04:07 +04:00
using Contracts.ViewModels;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
2024-06-26 08:04:07 +04:00
using System.Diagnostics.Eventing.Reader;
using WebApp.Helpers;
namespace WebApp.Pages
{
2024-06-26 08:04:07 +04:00
[Authorize(Roles = Roles.User)]
public class CartModel : PageModel
{
2024-06-26 08:04:07 +04:00
public PurchaseViewModel purchaseModel = null;
public Dictionary<Guid, int> Products { get; set; }
public void OnGet(Guid id, int count)
{
2024-06-26 08:04:07 +04:00
if (purchaseModel == null)
{
purchaseModel = APIClient.GetRequest<PurchaseViewModel>($"Purchase/Create/{this.GetUserId()}");
2024-06-26 08:04:07 +04:00
APIClient.GetRequest<PurchaseViewModel>($"Purchase/AddProducts?purchaseId={purchaseModel.Id}?productId={id}?count={count}");
}
purchaseModel = APIClient.GetRequest<PurchaseViewModel>($"Purchase/Get/");
Products = APIClient.GetRequest<Dictionary<Guid, int>>($"Purchase/GetProducts?id={purchaseModel.Id}");
}
public IActionResult OnPostAsync()
{
return RedirectToAction("");
}
}
2024-06-26 08:04:07 +04:00
}