public async Task <IActionResult> Edit(string id) { var result = await genericRepository.GetByID(new Guid(id)); if (result != null) { var model = new EditemployeeViewModel() { Id = result.Id.ToString(), Name = result.Name, Email = result.Email, Department = result.Department }; return(View(model)); } return(View("Error")); }
public async Task <IActionResult> Edit(EditemployeeViewModel model) { if (ModelState.IsValid) { var employee = await genericRepository.GetByID(new Guid(model.Id)); if (employee != null) { employee.Name = model.Name; employee.Email = model.Email; employee.Department = model.Department; employee.ModifiedDate = DateTime.Now; await genericRepository.Update(employee); return(View("Index", genericRepository.GetAll())); } } return(View("Error")); }