public IActionResult EditSocialData(AppDataUpdateViewModel model) { if (ModelState.IsValid) { AppSocialAddress item = _appRepository.GetInfo(model.Id); item.UrlAddress = model.UrlAddress; if (model.AppSocialImgs != null) { if (model.ExistingSocialImagePath != null) { string filePath = Path.Combine(_hostingEnvironment.WebRootPath, "images", model.ExistingSocialImagePath); System.IO.File.Delete(filePath); } item.AppSocialImg = ProcessUploadAppSocialImage(model); } _appRepository.Update(item); TempData["message"] = $"Object {item.UrlAddress} was edited."; return(RedirectToAction("SocialList")); } return(View()); }