public ActionResult AjaxForm() { var model = new DistrictItem(); if (DoAction == ActionType.Edit) { model = _api.GetDistrictItem(ArrId.FirstOrDefault()); } ViewBag.listCity = _cityApi.GetAll(); ViewBag.Action = DoAction; return(View(model)); }
public async Task <IActionResult> OnGetAsync(long?id) { if (id == null) { return(NotFound()); } DistrictItem = await _context.Districts.SingleOrDefaultAsync(m => m.Id == id); if (DistrictItem == null) { return(NotFound()); } return(Page()); }
public async Task <IActionResult> OnPostAsync(long?id) { if (id == null) { return(NotFound()); } DistrictItem = await _context.Districts.FindAsync(id); if (DistrictItem != null) { _context.Districts.Remove(DistrictItem); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }