public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.Customers.Add(Customer); await _context.SaveChangesAsync(); return(RedirectToPage("/MyAccount")); }
public async Task OnPostDeleteTraveler(string id) { var traveler = _context.Customers.Include(p => p.Passport).FirstOrDefault(x => x.CustomerId == id); var passport = traveler.Passport; if (traveler != null) { _context.Customers.Remove(traveler); _context.Passports.Remove(passport); await _context.SaveChangesAsync(); } Response.Redirect("/MyAccount"); }
public async Task AddObject(Customer o) { dbSet.Add(o); await _context.SaveChangesAsync(); }