public ActionResult EditContent(EditContentItemViewModel model) { //if (String.IsNullOrEmpty(model.Content.Body)) // ModelState.AddModelError("Content.Body", "Required"); if (ModelState.IsValid) { var content = model.Inserting() ? new Content { } : model.NavigationModel.Page.Modules[model.Mdx].Content[model.Idx]; if (model.Inserting()) { if (model.NavigationModel.Page.Modules.Count == 0) { model.NavigationModel.Page.Modules.Add(new Module { }); } model.NavigationModel.Page.Modules[model.Mdx].Content.Add(content); } content.Title = model.Content.Title; content.Body = model.Content.Body; content.ShowTitle = model.Content.ShowTitle; content.Priority = model.Content.Priority; content.ImageId = model.Content.ImageId; content.FileId = model.Content.FileId; content.DatePublished = model.Content.DatePublished; content.ShowAddThis = model.Content.ShowAddThis; content.BorderImage = model.Content.BorderImage; _service.SavePage(model.NavigationModel.Page); Message("Content Saved"); return(RedirectToAction("Index", new { id = model.NavigationModel.Page.PageNavigation.Id })); } model.Images = _service.GetImages(); model.Files = _service.Dal.FileProvider.Get(); model.NavigationModel = HomeIndexViewModelLoader.Create(model.NavigationModel.Page.PageNavigation.Id, _service); return(View(model)); }
public ActionResult EditContent(int Idx, int pageId, int Mdx) { var page = _service.GetPage(pageId); var model = new EditContentItemViewModel { Mdx = Mdx, Idx = Idx, NavigationModel = HomeIndexViewModelLoader.Create(pageId, _service), Images = _service.GetImages(), Files = _service.Dal.FileProvider.Get() }; model.Content = model.Inserting() ? new Content { } : page.Modules[Mdx].Content[Idx]; return(View(model)); }