public PageContent AddNewPage(Page page, string text, string editedBy, DateTime editedOn) { 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, }; UnitOfWork.Add(pageContentEntity); UnitOfWork.SaveChanges(); PageContent pageContent = FromEntity.ToPageContent(pageContentEntity); pageContent.Page = FromEntity.ToPage(pageEntity); return(pageContent); }
public PageContent AddNewPage(Page page, string text, string editedBy, DateTime editedOn, DateTime projectStart, DateTime projectEnd, bool projectEstimatedTime, string projectStatus, 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, }; UnitOfWork.Add(pageContentEntity); UnitOfWork.SaveChanges(); PageContent pageContent = FromEntity.ToPageContent(pageContentEntity); pageContent.Page = FromEntity.ToPage(pageEntity); return(pageContent); }
public PageContent AddNewPageContentVersion(Page page, string text, string editedBy, DateTime editedOn, int version, DateTime projectStart, DateTime projectEnd, bool projectEstimatedTime, string projectStatus, 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, }; 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); }
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); }
public Page GetPageByTitle(string title) { PageEntity entity = Pages.FirstOrDefault(p => p.Title.ToLower() == title.ToLower()); return(FromEntity.ToPage(entity)); }
public Page GetPageById(int id) { PageEntity entity = Pages.FirstOrDefault(p => p.Id == id); return(FromEntity.ToPage(entity)); }