public async Task <IActionResult> Edit(int id, [Bind("CostumerId,Name,BirthDate,Location,Password,ConfirmPassword")] Customers customers) { if (id != customers.CostumerId) { return(NotFound()); } if (ModelState.IsValid) { try { var user = await userManager.Users.FirstOrDefaultAsync(m => m.UserName == customers.Name); var userName = await userManager.FindByNameAsync(user.UserName); identityResult = await userManager.UpdateAsync(userName); _context.Update(customers); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CustomerExists(customers.CostumerId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(customers)); }
public async Task <IActionResult> Edit([Bind("CarRentID,ClientID,CarModel,StartDate,EndDate,City")] CarRent carRent) { if (ModelState.IsValid) { DateTime startDate = carRent.StartDate; DateTime endDate = carRent.EndDate; int clientIDEdit = carRent.ClientID; if (startDate > endDate || clientIDEdit == 0) { return(RedirectToAction(nameof(Edit))); } else { _context.Update(carRent); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } } return(View(carRent)); }