39 lines
934 B
C#
39 lines
934 B
C#
using Application.Aggregates.Stores;
|
|
using Application.Aggregates.Stores.ViewModels;
|
|
using Application.Aggregates.Users;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.AspNetCore.Mvc.RazorPages;
|
|
|
|
namespace Server.Pages.Panel.Stores;
|
|
|
|
public class DeleteModel(StoresApplication storesApplication) : PageModel
|
|
{
|
|
[BindProperty]
|
|
public StoreViewModel DeleteViewModel { get; set; } = new();
|
|
|
|
public async Task<IActionResult> OnGetAsync(Guid id)
|
|
{
|
|
if (id == Guid.Empty)
|
|
{
|
|
return RedirectToPage("Index");
|
|
}
|
|
|
|
DeleteViewModel =
|
|
await storesApplication.GetAsync(id);
|
|
|
|
if (DeleteViewModel == null)
|
|
{
|
|
return RedirectToPage("Index");
|
|
}
|
|
|
|
return Page();
|
|
}
|
|
|
|
public async Task<IActionResult> OnPostAsync()
|
|
{
|
|
await storesApplication.DeleteAsync(DeleteViewModel.Id);
|
|
|
|
return RedirectToPage("Index");
|
|
}
|
|
}
|