public async Task <IActionResult> Edit(int id, ServiceType servicetype) { if (id != servicetype.Id) { return(NotFound()); } if (ModelState.IsValid) { try { // servicetype.User = await _userHelper.GetUserByEmailAsync(this.User.Identity.Name); await _serviceTypeRepository.UpdateAsync(servicetype); } catch (DbUpdateConcurrencyException) { if (!await _serviceTypeRepository.ExistAsync(servicetype.Id))//!ServiceTypeExists(ServiceType.Id) < -original code { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(servicetype)); }