Beispiel #1
0
        public PageContent AddNewPageContentVersion(Page page, string text, string editedBy, DateTime editedOn, int version, DateTime projectStart, DateTime projectEnd, bool projectEstimatedTime, string projectStatus, Phase2Params phase2Params, string projectLanguage, int orgID)
        {
            if (version < 1)
            {
                version = 1;
            }

            PageEntity pageEntity = UnitOfWork.FindById <PageEntity>(page.Id);

            if (pageEntity != null)
            {
                // Update the content
                PageContentEntity pageContentEntity = new PageContentEntity()
                {
                    Id                         = Guid.NewGuid(),
                    Page                       = pageEntity,
                    Text                       = text,
                    EditedBy                   = editedBy,
                    EditedOn                   = editedOn,
                    VersionNumber              = version,
                    ProjectStart               = projectStart,
                    ProjectEnd                 = projectEnd,
                    ProjectEstimatedTime       = projectEstimatedTime,
                    ProjectStatus              = projectStatus,
                    ProjectLanguage            = projectLanguage,
                    orgID                      = orgID,
                    Owner                      = phase2Params.Owner,
                    OwnerEmail                 = phase2Params.OwnerEmail,
                    Department                 = phase2Params.Department,
                    CollaborationLevel         = phase2Params.CollaborationLevel,
                    FundingBoundary            = phase2Params.FundingBoundary,
                    ProjectAgileLifeCyclePhase = phase2Params.ProjectAgileLifeCyclePhase,
                };

                UnitOfWork.Add(pageContentEntity);
                UnitOfWork.SaveChanges();

                // The page modified fields
                pageEntity.ModifiedOn = editedOn;
                pageEntity.ModifiedBy = editedBy;
                UnitOfWork.SaveChanges();

                // Turn the content database entity back into a domain object



                PageContent pageContent = PageContent.FromPageContentEntity(pageContentEntity);
                pageContent.Page = Page.FromPageEntity(pageEntity);

                return(pageContent);
            }

            Log.Error("Unable to update page content for page id {0} (not found)", page.Id);
            return(null);
        }
Beispiel #2
0
        /// <summary>
        /// This updates an existing set of text and is used for page rename updates.
        /// To add a new version of a page, use AddNewPageContentVersion
        /// </summary>
        /// <param name="content"></param>
        public void UpdatePageContent(PageContent content)
        {
            PageContentEntity entity = UnitOfWork.FindById <PageContentEntity>(content.Id);

            if (entity != null)
            {
                ToEntity.FromPageContent(content, entity);
                UnitOfWork.SaveChanges();
                content = PageContent.FromPageContentEntity(entity);
            }
        }
Beispiel #3
0
        public static IEnumerable <PageContent> ToPageContentList(IEnumerable <PageContentEntity> entities)
        {
            List <PageContent> list = new List <PageContent>();

            foreach (PageContentEntity entity in entities)
            {
                PageContent pageContent = PageContent.FromPageContentEntity(entity);
                list.Add(pageContent);
            }

            return(list);
        }
Beispiel #4
0
        public PageContent AddNewPage(Page page, string text, string editedBy, DateTime editedOn, DateTime projectStart, DateTime projectEnd, bool projectEstimatedTime, string projectStatus, Phase2Params phase2Params, string projectLanguage, int orgID)
        {
            PageEntity pageEntity = new PageEntity();

            ToEntity.FromPage(page, pageEntity);
            pageEntity.Id = 0;
            UnitOfWork.Add(pageEntity);
            UnitOfWork.SaveChanges();

            PageContentEntity pageContentEntity = new PageContentEntity()
            {
                Id                         = Guid.NewGuid(),
                Page                       = pageEntity,
                Text                       = text,
                EditedBy                   = editedBy,
                EditedOn                   = editedOn,
                VersionNumber              = 1,
                ProjectStart               = projectStart,
                ProjectEnd                 = projectEnd,
                ProjectEstimatedTime       = projectEstimatedTime,
                ProjectStatus              = projectStatus,
                ProjectLanguage            = projectLanguage,
                orgID                      = orgID,
                Owner                      = phase2Params.Owner,
                OwnerEmail                 = phase2Params.OwnerEmail,
                Department                 = phase2Params.Department,
                CollaborationLevel         = phase2Params.CollaborationLevel,
                ProjectAgileLifeCyclePhase = phase2Params.ProjectAgileLifeCyclePhase,
                FundingBoundary            = phase2Params.FundingBoundary
            };

            UnitOfWork.Add(pageContentEntity);
            UnitOfWork.SaveChanges();

            PageContent pageContent = PageContent.FromPageContentEntity(pageContentEntity);

            pageContent.Page = Page.FromPageEntity(pageEntity);
            return(pageContent);
        }
Beispiel #5
0
        public PageContent GetPageContentByPageIdAndVersionNumber(int id, int versionNumber)
        {
            PageContentEntity entity = PageContents.FirstOrDefault(p => p.Page.Id == id && p.VersionNumber == versionNumber);

            return(PageContent.FromPageContentEntity(entity));
        }
Beispiel #6
0
        public PageContent GetPageContentById(Guid id)
        {
            PageContentEntity entity = PageContents.FirstOrDefault(p => p.Id == id);

            return(PageContent.FromPageContentEntity(entity));
        }
Beispiel #7
0
        public PageContent GetLatestPageContent(int pageId)
        {
            PageContentEntity entity = PageContents.Where(x => x.Page.Id == pageId).OrderByDescending(x => x.EditedOn).FirstOrDefault();

            return(PageContent.FromPageContentEntity(entity));
        }