60 lines
1.4 KiB
C#
60 lines
1.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.AspNetCore.Mvc.RazorPages;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using FakturyWeb.Data;
|
|
using RazorPagesMovie.Models;
|
|
|
|
namespace FakturyWeb.Pages.Zakaznik
|
|
{
|
|
public class DeleteModel : PageModel
|
|
{
|
|
private readonly FakturyWeb.Data.FakturyWebContext _context;
|
|
|
|
public DeleteModel(FakturyWeb.Data.FakturyWebContext context)
|
|
{
|
|
_context = context;
|
|
}
|
|
|
|
[BindProperty]
|
|
public ZAKAZNIK ZAKAZNIK { get; set; }
|
|
|
|
public async Task<IActionResult> OnGetAsync(int? id)
|
|
{
|
|
if (id == null)
|
|
{
|
|
return NotFound();
|
|
}
|
|
|
|
ZAKAZNIK = await _context.ZAKAZNIK.FirstOrDefaultAsync(m => m.ID == id);
|
|
|
|
if (ZAKAZNIK == null)
|
|
{
|
|
return NotFound();
|
|
}
|
|
return Page();
|
|
}
|
|
|
|
public async Task<IActionResult> OnPostAsync(int? id)
|
|
{
|
|
if (id == null)
|
|
{
|
|
return NotFound();
|
|
}
|
|
|
|
ZAKAZNIK = await _context.ZAKAZNIK.FindAsync(id);
|
|
|
|
if (ZAKAZNIK != null)
|
|
{
|
|
_context.ZAKAZNIK.Remove(ZAKAZNIK);
|
|
await _context.SaveChangesAsync();
|
|
}
|
|
|
|
return RedirectToPage("./Index");
|
|
}
|
|
}
|
|
}
|