public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.Attach(CouponCategory).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CouponCategoryExists(CouponCategory.Id)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { ViewData["CategoryId"] = new SelectList(_context.CouponCategories, "Id", "Name"); ViewData["CustomerId"] = new SelectList(_context.Customers, "Id", "Name"); ViewData["SellerId"] = new SelectList(_context.Sellers, "Id", "Name"); return(Page()); } _context.Attach(Coupon).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CouponExists(Coupon.Id)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.CouponCategories.Add(CouponCategory); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { ViewData["CategoryId"] = new SelectList(_context.CouponCategories, "Id", "Name"); ViewData["CustomerId"] = new SelectList(_context.Customers, "Id", "Name"); ViewData["SellerId"] = new SelectList(_context.Sellers, "Id", "Name"); return(Page()); } _context.Coupons.Add(Coupon); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Seller = await _context.Sellers.FindAsync(id); if (Seller != null) { _context.Sellers.Remove(Seller); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } CouponCategory = await _context.CouponCategories.FindAsync(id); if (CouponCategory != null) { _context.CouponCategories.Remove(CouponCategory); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }