// To protect from overposting attacks, enable the specific properties you want to bind to, for // more details, see https://aka.ms/RazorPagesCRUD. public async Task <IActionResult> OnPostAsync() { ViewData["SalesOfficeId"] = new SelectList(_context.Set <SalesOffice>(), "Id", "Name"); if (!ModelState.IsValid) { return(Page()); } //Perform validation for Duplicate License# int AgentCount = _context.Agent.Count(x => x.LicenseNumber == Agent.LicenseNumber); if (AgentCount > 0) { ModelState.AddModelError("Agent.LicenseNumber", "Agent with this License Number already exists"); } //Recheck Validation Status if (!ModelState.IsValid) { return(Page()); } _context.Agent.Add(Agent); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); }
// To protect from overposting attacks, 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()); } //Perform validation for Phone Number# int PhoneNumber = _context.Buyer.Count(x => x.PhoneNumber == Buyer.PhoneNumber); if (PhoneNumber > 0) { ModelState.AddModelError("Buyer.PhoneNumber", "This Phone Number already exists"); } if (!ModelState.IsValid) { return(Page()); } _context.Buyer.Add(Buyer); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); }
// To protect from overposting attacks, 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(Buyer).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BuyerExists(Buyer.Id)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Index")); }
// To protect from overposting attacks, 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.SalesOffice.Add(SalesOffice); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Agent = await _context.Agent.FindAsync(id); if (Agent != null) { _context.Agent.Remove(Agent); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } SalesOffice = await _context.SalesOffice.FindAsync(id); if (SalesOffice != null) { _context.SalesOffice.Remove(SalesOffice); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Dwelling = await _context.Dwelling.FindAsync(id); if (Dwelling != null) { _context.Dwelling.Remove(Dwelling); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
// To protect from overposting attacks, 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()); } var currentDate = DateTime.Today; var dateAdded = Dwelling.DateAdded.Date; if (dateAdded > currentDate) { ModelState.AddModelError("Dwelling.DateAdded", "Date Added can't be a future date"); } if (!ModelState.IsValid) { return(Page()); } _context.Attach(Dwelling).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DwellingExists(Dwelling.Id)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Index")); }
// To protect from overposting attacks, 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()); } //Perform validation for Duplicate License# int AgentCount = _context.Agent.Count(x => x.Id != Agent.Id && x.LicenseNumber == Agent.LicenseNumber); if (AgentCount > 0) { ModelState.AddModelError("Agent.LicenseNumber", "Agent with this License Number already exists"); } //Recheck Validation Status if (!ModelState.IsValid) { return(Page()); } _context.Attach(Agent).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AgentExists(Agent.Id)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Index")); }
// To protect from overposting attacks, 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()); } var currentDate = DateTime.Today; var dateAdded = Dwelling.DateAdded.Date; if (dateAdded > currentDate) { ModelState.AddModelError("Dwelling.DateAdded", "Date Added can't be a future date"); } if (!ModelState.IsValid) { return(Page()); } _context.Dwelling.Add(Dwelling); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); }