public IActionResult edit(int id) { Home home = _employeerepository.GetHome(id); HomeeditViewModel homeeditViewModel = new HomeeditViewModel() { Id = home.id, Name = home.Name, Email = home.Email, Department = home.Department, Existingphoto = home.photopath }; return(View(homeeditViewModel)); }
public IActionResult edit(HomeeditViewModel model) { if (ModelState.IsValid) { Home homes = _employeerepository.GetHome(model.Id); homes.Name = model.Name; homes.Email = model.Email; homes.Department = model.Department; if (model.photos != null) { if (model.Existingphoto != null) { string filepath = Path.Combine(hostingEnvironment.WebRootPath, "images", model.Existingphoto); System.IO.File.Delete(filepath); } homes.photopath = ProcessUploadFile(model); } _employeerepository.update(homes); return(RedirectToAction("index")); } return(View()); }