public async Task <IActionResult> Edit(int id, [Bind("Id,Discount,DiscountCode,discountpercentage")] DiscountVoucher discountVoucher) { if (id != discountVoucher.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(discountVoucher); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DiscountVoucherExists(discountVoucher.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(discountVoucher)); }
public async Task <IActionResult> Create([Bind("Id,Discount,DiscountCode,discountpercentage")] DiscountVoucher discountVoucher) { if (ModelState.IsValid) { _context.Add(discountVoucher); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(discountVoucher)); }