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); }