// 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()); } //Customer CustId = new Customer(); _context.Attach(Order).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!OrderExists(Order.OrderId)) { 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.Attach(Product).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProductExists(Product.ProductId)) { 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()); } int ph_length = Customer.PhoneNumber.Length; int birthYear = Customer.DOB.Year; int lastAllowedYear = DateTime.Now.Year - 18; if (ph_length != 10) { ModelState.AddModelError(key: "Customer.PhoneNumber", errorMessage: "Phone number must be 10 digits"); } if (birthYear > lastAllowedYear) { ModelState.AddModelError(key: "Customer.DOB", errorMessage: "Must be older than 18 years"); } if (!ModelState.IsValid) { return(Page()); } _context.Customer.Add(Customer); await _context.SaveChangesAsync(); TempData["notice"] = "Welcome" + Customer.LastName; 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.Order.Add(Order); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } ProductOrder = await _context.ProductOrder.FindAsync(id); if (ProductOrder != null) { _context.ProductOrder.Remove(ProductOrder); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } CreditCard = await _context.CreditCard.FindAsync(id); if (CreditCard != null) { _context.CreditCard.Remove(CreditCard); 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(Customer).State = EntityState.Modified; int ph_length = Customer.PhoneNumber.Length; int birthYear = Customer.DOB.Year; int lastAllowedYear = DateTime.Now.Year - 18; if (ph_length != 10) { ModelState.AddModelError(key: "Customer.PhoneNumber", errorMessage: "Phone Number must be 10 digits"); } if (birthYear > lastAllowedYear) { ModelState.AddModelError(key: "Customer.DOB", errorMessage: "Must be older than 18 years"); } if (!ModelState.IsValid) { return(Page()); } try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CustomerExists(Customer.CustomerId)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Index")); }