public async Task <IActionResult> Edit(int id, [Bind("ID_DiscountUsed,ID_Account,ID_Discount")] DiscountUsed discountUsed) { if (id != discountUsed.ID_DiscountUsed) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(discountUsed); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DiscountUsedExists(discountUsed.ID_DiscountUsed)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["ID_Account"] = new SelectList(_context.Account, "ID_Account", "Email", discountUsed.ID_Account); ViewData["ID_Discount"] = new SelectList(_context.Discount, "ID_Discount", "Code_Discount", discountUsed.ID_Discount); return(View(discountUsed)); }
public async Task <IActionResult> Create([Bind("ID_DiscountUsed,ID_Account,ID_Discount")] DiscountUsed discountUsed) { if (ModelState.IsValid) { _context.Add(discountUsed); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["ID_Account"] = new SelectList(_context.Account, "ID_Account", "Email", discountUsed.ID_Account); ViewData["ID_Discount"] = new SelectList(_context.Discount, "ID_Discount", "Code_Discount", discountUsed.ID_Discount); return(View(discountUsed)); }