/// <summary> /// Constructor for building a new object with MinimalConstructor required fields, using objects whenever possible /// </summary> public CustomPageRole(CustomPage customPage) : this() { // Mark this as a new object by setting primary key with special value this.CustomPageRoleID = ModelObjectHelpers.MakeNextUnsavedPrimaryKeyValue(); this.CustomPageID = customPage.CustomPageID; this.CustomPage = customPage; customPage.CustomPageRoles.Add(this); }
public ViewPageContentViewData(ProjectFirmaModels.Models.CustomPage customPage, bool showEditButton) { FirmaPageContentHtmlString = customPage.GetFirmaPageContentHtmlString(); FirmaPageDisplayName = customPage.GetFirmaPageDisplayName(); ShowEditButton = showEditButton; HasPageContent = customPage.HasPageContent(); EditPageContentUrl = SitkaRoute <CustomPageController> .BuildUrlFromExpression(t => t.EditInDialog(customPage)); }
/// <summary> /// Constructor for building a new object with MinimalConstructor required fields, using objects whenever possible /// </summary> public CustomPageImage(CustomPage customPage, FileResourceInfo fileResourceInfo) : this() { // Mark this as a new object by setting primary key with special value this.CustomPageImageID = ModelObjectHelpers.MakeNextUnsavedPrimaryKeyValue(); this.CustomPageID = customPage.CustomPageID; this.CustomPage = customPage; customPage.CustomPageImages.Add(this); this.FileResourceInfoID = fileResourceInfo.FileResourceInfoID; this.FileResourceInfo = fileResourceInfo; fileResourceInfo.CustomPageImages.Add(this); }
public EditViewModel(ProjectFirmaModels.Models.CustomPage customPage) { CustomPageID = customPage.CustomPageID; FirmaMenuItemID = customPage.FirmaMenuItemID; CustomPageDisplayName = customPage.CustomPageDisplayName; CustomPageVanityUrl = customPage.CustomPageVanityUrl; ViewableByAnonymous = customPage.CustomPageRoles.Any(x => x.RoleID == null); ViewableByUnassigned = customPage.CustomPageRoles.Any(x => x.RoleID == ProjectFirmaModels.Models.Role.Unassigned.RoleID); ViewableByNormal = customPage.CustomPageRoles.Any(x => x.RoleID == ProjectFirmaModels.Models.Role.Normal.RoleID); ViewableByProjectSteward = customPage.CustomPageRoles.Any(x => x.RoleID == ProjectFirmaModels.Models.Role.ProjectSteward.RoleID); ViewableByAdmin = customPage.CustomPageRoles.Any(x => x.RoleID == ProjectFirmaModels.Models.Role.Admin.RoleID); }
public void UpdateModel(ProjectFirmaModels.Models.CustomPage customPage, DatabaseEntities databaseEntities) { // delete file resources for any images that are no longer referenced in the HTML var imagesToDelete = CustomPageContentHtmlString == null ? customPage.CustomPageImages.ToList() : customPage.CustomPageImages.Where(x => !CustomPageContentHtmlString.ToString().ContainsCaseInsensitive(x.FileResourceInfo.GetFileResourceGUIDAsString())).ToList(); foreach (var image in imagesToDelete) { // will cascade delete the CustomPageImage image.FileResourceInfo.DeleteFull(databaseEntities); } customPage.CustomPageContentHtmlString = CustomPageContentHtmlString == null || string.IsNullOrWhiteSpace(CustomPageContentHtmlString.ToString()) ? null : CustomPageContentHtmlString; }
public void UpdateModel(ProjectFirmaModels.Models.CustomPage customPage, FirmaSession currentFirmaSession, ICollection <CustomPageRole> allCustomPageRoles) { customPage.FirmaMenuItemID = FirmaMenuItemID; customPage.CustomPageDisplayName = CustomPageDisplayName; customPage.CustomPageVanityUrl = CustomPageVanityUrl; var newCustomPageRoles = new List <CustomPageRole>(); if (ViewableByAnonymous) { newCustomPageRoles.Add(new CustomPageRole(customPage.CustomPageID)); } if (ViewableByUnassigned) { newCustomPageRoles.Add(new CustomPageRole(customPage.CustomPageID) { RoleID = ProjectFirmaModels.Models.Role.Unassigned.RoleID }); } if (ViewableByNormal) { newCustomPageRoles.Add(new CustomPageRole(customPage.CustomPageID) { RoleID = ProjectFirmaModels.Models.Role.Normal.RoleID }); } if (ViewableByProjectSteward) { newCustomPageRoles.Add(new CustomPageRole(customPage.CustomPageID) { RoleID = ProjectFirmaModels.Models.Role.ProjectSteward.RoleID }); } if (ViewableByAdmin) { newCustomPageRoles.Add(new CustomPageRole(customPage.CustomPageID) { RoleID = ProjectFirmaModels.Models.Role.Admin.RoleID }); } customPage.CustomPageRoles.Merge(newCustomPageRoles, allCustomPageRoles, (x, y) => x.CustomPageID == y.CustomPageID && x.RoleID == y.RoleID, HttpRequestStorage.DatabaseEntities); }
public DisplayDocumentLibraryViewData(ProjectFirmaModels.Models.CustomPage customPage, FirmaSession currentFirmaSession) { if (customPage.DocumentLibrary != null) { UserHasAdminPermissions = new FirmaAdminFeature().HasPermissionByFirmaSession(currentFirmaSession); DocumentLibraryUrl = SitkaRoute <DocumentLibraryController> .BuildUrlFromExpression(c => c.Detail(customPage.DocumentLibrary)); DocumentCategories = customPage.DocumentLibrary.DocumentLibraryDocumentCategories.Select(x => x.DocumentCategory).OrderBy(x => x.SortOrder).ToList(); Documents = customPage.DocumentLibrary.DocumentLibraryDocuments.Where(x => x.HasViewPermission(currentFirmaSession)).ToList(); ShowDocumentLibrary = Documents.Any() || UserHasAdminPermissions; TotalDocumentCountPerCategory = new Dictionary <int, int>(); ViewableDocumentCountPerCategory = new Dictionary <int, int>(); if (ShowDocumentLibrary) { foreach (var documentCategory in DocumentCategories) { TotalDocumentCountPerCategory.Add(documentCategory.DocumentCategoryID, customPage.DocumentLibrary.DocumentLibraryDocuments.Count(x => x.DocumentCategoryID == documentCategory.DocumentCategoryID)); ViewableDocumentCountPerCategory.Add(documentCategory.DocumentCategoryID, Documents.Count(x => x.DocumentCategoryID == documentCategory.DocumentCategoryID)); } } } }
/// <summary> /// Creates a "blank" object of this type and populates primitives with defaults /// </summary> public static CustomPageRole CreateNewBlank(CustomPage customPage) { return(new CustomPageRole(customPage)); }
public DisplayPageContentViewData(FirmaSession currentFirmaSession, ProjectFirmaModels.Models.CustomPage customPage, bool showEditButton) : base(currentFirmaSession) { PageTitle = customPage.GetFirmaPageDisplayName(); ViewWholePageContentViewData = new ViewPageContentViewData(customPage, showEditButton); DisplayDocumentLibraryViewData = new DisplayDocumentLibraryViewData(customPage, currentFirmaSession); }
/// <summary> /// Creates a "blank" object of this type and populates primitives with defaults /// </summary> public static CustomPageImage CreateNewBlank(CustomPage customPage, FileResourceInfo fileResourceInfo) { return(new CustomPageImage(customPage, fileResourceInfo)); }
public EditHtmlContentInDialogViewModel(ProjectFirmaModels.Models.CustomPage customPage) { CustomPageContentHtmlString = customPage != null ? customPage.CustomPageContentHtmlString : null; }