public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.Attach(StaffAreaAccess).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!StaffAreaAccessExists(StaffAreaAccess.StaffId)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync() { // check model is valid and check that an organisation and a site are selected if (!ModelState.IsValid || Organisation.Name == "test" || Visit.SiteId == 0) { await OnGetAsync(); return(Page()); } // create new organisation if does not already exist if (!(_context.Organisation.Any(organisation => organisation.Name == Organisation.Name))) { _context.Organisation.Add(Organisation); await _context.SaveChangesAsync(); Visitor.OrganisationId = Organisation.OrganisationId; } else { // based on the organisation name get its ID int orgId = (from organisation in _context.Organisation where organisation.Name == Organisation.Name select organisation.OrganisationId).SingleOrDefault(); Visitor.OrganisationId = orgId; } // create new user if does not already exist (check passport/licence number) if (!(_context.Visitor.Any(visitor => visitor.IdentificationNumber == Visitor.IdentificationNumber))) { // create new visitor record _context.Visitor.Add(Visitor); await _context.SaveChangesAsync(); // use new visitor id in visit record Visit.VisitorId = Visitor.VisitorId; } // [TODO] warn staff if using same identification number but with a different name _context.Visit.Add(Visit); await _context.SaveChangesAsync(); return(RedirectToPage("./SignIn")); }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.Organisation.Add(Organisation); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.StaffAreaAccess.Add(StaffAreaAccess); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Organisation = await _context.Organisation.FindAsync(id); if (Organisation != null) { _context.Organisation.Remove(Organisation); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Visit = await _context.Visit.FindAsync(id); if (Visit != null) { _context.Visit.Remove(Visit); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } StaffAreaAccess = await _context.StaffAreaAccess.FindAsync(id); if (StaffAreaAccess != null) { _context.StaffAreaAccess.Remove(StaffAreaAccess); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }