Exemplo n.º 1
0
        public static Page ToPage(PageEntity entity)
        {
            if (entity == null)
            {
                return(null);
            }

            Page page = new Page();

            page.Id         = entity.Id;
            page.CreatedBy  = entity.CreatedBy;
            page.CreatedOn  = entity.CreatedOn;
            page.IsLocked   = entity.IsLocked;
            page.ModifiedBy = entity.ModifiedBy;
            page.ModifiedOn = entity.ModifiedOn;
            page.Tags       = entity.Tags;
            page.Title      = entity.Title;

            return(page);
        }
Exemplo n.º 2
0
        public Page SaveOrUpdatePage(Page page)
        {
            PageEntity entity = UnitOfWork.FindById <PageEntity>(page.Id);

            if (entity == null)
            {
                entity = new PageEntity();
                ToEntity.FromPage(page, entity);
                UnitOfWork.Add(entity);
                UnitOfWork.SaveChanges();
                page = FromEntity.ToPage(entity);
            }
            else
            {
                ToEntity.FromPage(page, entity);
                UnitOfWork.SaveChanges();
                page = FromEntity.ToPage(entity);
            }

            return(page);
        }
Exemplo n.º 3
0
        public PageContent AddNewPageContentVersion(Page page, string text, string editedBy, DateTime editedOn, int version)
        {
            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,
                };

                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 = FromEntity.ToPageContent(pageContentEntity);
                pageContent.Page = FromEntity.ToPage(pageEntity);

                return(pageContent);
            }

            Log.Error("Unable to update page content for page id {0} (not found)", page.Id);
            return(null);
        }
Exemplo n.º 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);
        }
Exemplo n.º 5
0
        public static void FromPage(Page page, PageEntity entity)
        {
            entity.CreatedBy            = page.CreatedBy;
            entity.CreatedOn            = page.CreatedOn;
            entity.IsLocked             = page.IsLocked;
            entity.ModifiedOn           = page.ModifiedOn;
            entity.ModifiedBy           = page.ModifiedBy;
            entity.ProjectStart         = page.ProjectStart;
            entity.ProjectEnd           = page.ProjectEnd;
            entity.ProjectEstimatedTime = page.ProjectEstimatedTime;
            entity.ProjectStatus        = page.ProjectStatus;
            entity.ProjectLanguage      = page.ProjectLanguage;
            entity.orgID = page.orgID;
            entity.Tags  = page.Tags;
            entity.Title = page.Title;

            entity.Owner      = page.Owner;
            entity.OwnerEmail = page.OwnerEmail;
            entity.Department = page.Department;
            entity.ProjectAgileLifeCyclePhase = page.ProjectAgileLifeCyclePhase;
            entity.CollaborationLevel         = page.CollaborationLevel;
            entity.FundingBoundary            = page.FundingBoundary;
        }
Exemplo n.º 6
0
        public Page GetPageByTitle(string title)
        {
            PageEntity entity = Pages.FirstOrDefault(p => p.Title.ToLower() == title.ToLower());

            return(FromEntity.ToPage(entity));
        }
Exemplo n.º 7
0
        public Page GetPageById(int id)
        {
            PageEntity entity = Pages.FirstOrDefault(p => p.Id == id);

            return(FromEntity.ToPage(entity));
        }