PIAPS_CW/WebApp/Pages/Cart.cshtml.cs
2024-06-26 08:04:07 +04:00

35 lines
1.1 KiB
C#

using Contracts.ViewModels;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using System.Diagnostics.Eventing.Reader;
using WebApp.Helpers;
namespace WebApp.Pages
{
[Authorize(Roles = Roles.User)]
public class CartModel : PageModel
{
public PurchaseViewModel purchaseModel = null;
public Dictionary<Guid, int> Products { get; set; }
public void OnGet(Guid id, int count)
{
if (purchaseModel == null)
{
purchaseModel = APIClient.GetRequest<PurchaseViewModel>($"Purchase/Create/{this.GetUserId()}");
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("");
}
}
}