public IActionResult Edit(int id, [Bind("Id,Name,Email,Username,Pwd,LastName")] Customer customer) { if (_context.FindByID(id).Username != customer.Username) //username cant be updated { return(NotFound()); } if (ModelState.IsValid) { try { _context.Edit(customer); } catch (Exception) { logger.LogError("Customer edit failed"); TempData["EditFailed"] = true; ModelState.AddModelError("EditFailed", "Updating the customer failed please try again later."); return(View(customer)); } logger.LogInformation("Successfully edited customer"); return(RedirectToAction(nameof(Index))); } return(View(customer)); }