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()); }
public IActionResult EditSocialData(int id) { AppSocialAddress data = _appRepository.GetInfo(id); AppDataUpdateViewModel item = new AppDataUpdateViewModel { Id = data.Id, UrlAddress = data.UrlAddress, ExistingSocialImagePath = data.AppSocialImg }; TempData["message"] = $"Object {item.UrlAddress} was selected."; return(View(item)); }