public ActionResult Edit(Content model) { try { var content = _repository.GetContent(model.Id); content.Name = string.IsNullOrEmpty(model.Name) ? SiteHelper.UpdatePageWebName(model.Name, model.Title) : SiteHelper.UpdatePageWebName(model.Name); TryUpdateModel(content, new[] { "Title", "TitleEng", "MenuTitle", "MenuTitleEng", "SeoDescription", "ContentType", "SeoKeywords", "Seotext", "SortOrder" }); //content.Text = model.Text == null ? "" : HttpUtility.HtmlDecode(model.Text); //content.TextEng = model.TextEng == null ? "" : HttpUtility.HtmlDecode(model.TextEng); var file = Request.Files[0]; if (file != null && !string.IsNullOrEmpty(file.FileName)) { if (!string.IsNullOrEmpty(content.ImageSource)) { ImageHelper.DeleteImage(content.ImageSource); } string fileName = IOHelper.GetUniqueFileName("~/Content/Images", file.FileName); string filePath = Server.MapPath("~/Content/Images"); filePath = Path.Combine(filePath, fileName); GraphicsHelper.SaveOriginalImage(filePath, fileName, file, 1500); content.ImageSource = fileName; } else { content.ImageSource = content.ImageSource ?? ""; } _repository.SaveContent(content); } catch (Exception ex) { TempData["errorMessage"] = ex.Message; return View(model); } return RedirectToAction("Index"); }
public void SaveContent(Content content) { var cache = _store.Contents.Single(c => c.Id == content.Id); _store.SaveChanges(); }