public ActionResult Edit(int id, [ModelBinder(typeof(PageContentModelBinder))] PageContentEditModel pageContentModel) { if (ModelState.IsValid) { PageContent objPageContent = _repPageContent.GetSingle(x => x.Id == id); if (objPageContent != null) { pageContentModel.PageUrl = CaseChange.TitleCase(pageContentModel.PageUrl); pageContentModel.PageName = CaseChange.TitleCase(pageContentModel.PageName); if (!pageContentModel.PageUrl.StartsWith("/")) { pageContentModel.PageUrl = "/" + pageContentModel.PageUrl; } PageContentMap.ApplyChanges(pageContentModel, objPageContent); if (!string.IsNullOrWhiteSpace(objPageContent.Content)) { _repPageContent.Update(objPageContent); _repPageContent.Save(); } else { //objPageContent.UpdateWithoutContent(); } } TempData[LeonniConstants.SuccessMessage] = "Page Content edited successfully"; return(RedirectToAction("Index")); } else { LoadLanguageDropdown(); return(View(pageContentModel)); } }
public PageContent AddOrUpdatePageContent(PageContent pageContent) { var result = _pageContentRepository.Get(pageContent.Id); if (result == null) { result = _pageContentRepository.Create(pageContent); var adminPermissions = AddAdminPermissions(result); if (result.ContentPermissions == null) { result.ContentPermissions = adminPermissions; } else { adminPermissions.AddRange(result.ContentPermissions); result.ContentPermissions = adminPermissions; } } else { pageContent.IsActive = true; result = _pageContentRepository.Update(pageContent); } return(result); }
public PageContent AddOrUpdatePageContent(PageContent pageContent) { try { PageContent result = _pageContentRepository.Get(pageContent.Id); if (result == null) { result = _pageContentRepository.Create(pageContent); List <ContentPermission> adminPermissions = AddAdminPermissions(result); if (result.ContentPermissions == null) { result.ContentPermissions = adminPermissions; } else { adminPermissions.AddRange(result.ContentPermissions); result.ContentPermissions = adminPermissions; } } else { pageContent.IsDeleted = false; result.Title = pageContent.Title; result.ContainerId = pageContent.ContainerId; result.SortOrder = pageContent.SortOrder; result.LastModifiedDate = DateTime.Now; result.Properties = pageContent.Properties; result = _pageContentRepository.Update(result); } return(result); } catch (Exception ex) { _logger.LogError(string.Format("Error occured while creating a page content"), ex); } return(null); }
private void DeleteModulesAndContent(PageLayout pageLayout) { //When page layout is being copied, all modules and contents should be deleted. var pageModules = _pageRepository.GetPageModules(pageLayout.PageId); var pageContents = _pageContentRepository.Get(pageLayout.PageId, Globals.FallbackLanguage); if (pageModules != null && pageModules.Count > 0) { foreach (var pageModule in pageModules) { pageModule.IsDeleted = true; _pageRepository.UpdatePageModule(pageModule); } } if (pageContents != null && pageContents.Count > 0) { foreach (var content in pageContents) { content.IsDeleted = true; _pageContentRepository.Update(content); } } }