public async Task <IActionResult> Edit(decimal id, [Bind("Id,Userid,Carid,Rentdate,Returndate,Totalprice")] Deletedrentalhistory deletedrentalhistory) { if (id != deletedrentalhistory.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(deletedrentalhistory); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DeletedrentalhistoryExists(deletedrentalhistory.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["Carid"] = new SelectList(_context.Cars, "Id", "Status", deletedrentalhistory.Carid); ViewData["Userid"] = new SelectList(_context.Users, "Id", "Birthplace", deletedrentalhistory.Userid); return(View(deletedrentalhistory)); }
public async Task <IActionResult> Create([Bind("Id,Userid,Carid,Rentdate,Returndate,Totalprice")] Deletedrentalhistory deletedrentalhistory) { if (ModelState.IsValid) { _context.Add(deletedrentalhistory); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["Carid"] = new SelectList(_context.Cars, "Id", "Status", deletedrentalhistory.Carid); ViewData["Userid"] = new SelectList(_context.Users, "Id", "Birthplace", deletedrentalhistory.Userid); return(View(deletedrentalhistory)); }