// To protect from overposting attacks, please enable the specific properties you want to bind to, for // more details see https://aka.ms/RazorPagesCRUD. public async Task <IActionResult> OnPostAsync() { Locations = _htmlHelper.GetEnumSelectList <City>(); Infected = _htmlHelper.GetEnumSelectList <Infected>(); PatientState = _htmlHelper.GetEnumSelectList <PatientState>(); Hospitals = new SelectList(_context.Hospitals.ToList(), "Id", "HospitalName", Patient.Hospital); if (!ModelState.IsValid) { return(Page()); } _context.Attach(Patient).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PatientExists(Patient.Id)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Index")); }
// To protect from overposting attacks, please enable the specific properties you want to bind to, for // more details see https://aka.ms/RazorPagesCRUD. public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.Attach(Hospital).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!HospitalExists(Hospital.Id)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Index")); }
// To protect from overposting attacks, please enable the specific properties you want to bind to, for // more details see https://aka.ms/RazorPagesCRUD. public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.Hospitals.Add(Hospital); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Patient = await _context.Patients.FindAsync(id); if (Patient != null) { _context.Patients.Remove(Patient); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Hospital = await _context.Hospitals.FindAsync(id); if (Hospital != null) { _context.Hospitals.Remove(Hospital); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }