Example #1
0
        public EditViewData(FirmaSession currentFirmaSession,
                            IEnumerable <MeasurementUnitType> measurementUnitTypes,
                            List <ProjectCustomAttributeDataType> projectCustomAttributeDataTypes,
                            List <ProjectFirmaModels.Models.Role> roles,
                            string submitUrl,
                            ProjectFirmaModels.Models.FirmaPage instructionsFirmaPage,
                            ProjectFirmaModels.Models.ProjectCustomAttributeType projectCustomAttributeType,
                            List <ProjectFirmaModels.Models.ProjectCustomAttributeGroup> allProjectCustomAttributeGroups)
            : base(currentFirmaSession)
        {
            EntityName = "Attribute Type";
            PageTitle  =
                $"{(projectCustomAttributeType != null ? "Edit" : "New")} Attribute Type";
            YesNos = BooleanFormats.GetYesNoSelectList();
            ProjectCustomAttributeDataTypes = projectCustomAttributeDataTypes.ToSelectListWithEmptyFirstRow(
                x => x.ProjectCustomAttributeDataTypeID.ToString(), x => x.ProjectCustomAttributeDataTypeDisplayName);
            ProjectCustomAttributeGroups = allProjectCustomAttributeGroups.ToSelectListWithEmptyFirstRow(x => x.ProjectCustomAttributeGroupID.ToString(), x => x.ProjectCustomAttributeGroupName);
            MeasurementUnitTypes         = measurementUnitTypes.OrderBy(x => x.MeasurementUnitTypeDisplayName)
                                           .ToSelectListWithEmptyFirstRow(
                x => x.MeasurementUnitTypeID.ToString(), x => x.MeasurementUnitTypeDisplayName,
                ViewUtilities.NoneString);
            ProjectCustomAttributeTypeIndexUrl =
                SitkaRoute <ProjectCustomAttributeTypeController> .BuildUrlFromExpression(x => x.Manage());

            SubmitUrl = submitUrl;

            ViewInstructionsFirmaPage = new ViewPageContentViewData(instructionsFirmaPage, currentFirmaSession);

            ViewDataForAngular = new EditViewDataForAngular(projectCustomAttributeDataTypes);
        }
Example #2
0
        public DetailViewData(FirmaSession currentFirmaSession,
                              ProjectFirmaModels.Models.ProjectCustomAttributeType projectCustomAttributeType) : base(currentFirmaSession)
        {
            ProjectCustomAttributeType = projectCustomAttributeType;
            EntityName = FieldDefinitionEnum.ProjectCustomAttribute.ToType().GetFieldDefinitionLabelPluralized();
            PageTitle  = projectCustomAttributeType.ProjectCustomAttributeTypeName;
            ManageUrl  = SitkaRoute <ProjectCustomAttributeTypeController> .BuildUrlFromExpression(c => c.Manage());

            UserHasProjectCustomAttributeTypeManagePermissions = new FirmaAdminFeature().HasPermissionByFirmaSession(currentFirmaSession);

            ProjectTypeGridName    = "projectTypeGridForAttribute";
            ProjectTypeGridDataUrl = "#";
        }
Example #3
0
 public EditViewModel(ProjectFirmaModels.Models.ProjectCustomAttributeType projectCustomAttributeType)
 {
     ProjectCustomAttributeTypeID            = projectCustomAttributeType.ProjectCustomAttributeTypeID;
     ProjectCustomAttributeTypeName          = projectCustomAttributeType.ProjectCustomAttributeTypeName;
     ProjectCustomAttributeDataTypeID        = projectCustomAttributeType.ProjectCustomAttributeDataTypeID;
     MeasurementUnitTypeID                   = projectCustomAttributeType.MeasurementUnitTypeID;
     ProjectCustomAttributeTypeOptionsSchema = projectCustomAttributeType.ProjectCustomAttributeTypeOptionsSchema;
     IsRequired = projectCustomAttributeType.IsRequired;
     ProjectCustomAttributeTypeDesription = projectCustomAttributeType.ProjectCustomAttributeTypeDescription;
     EditableByNormal              = projectCustomAttributeType.ProjectCustomAttributeTypeRoles.Any(x => x.ProjectCustomAttributeTypeRolePermissionType == ProjectCustomAttributeTypeRolePermissionType.Edit && x.RoleID == ProjectFirmaModels.Models.Role.Normal.RoleID);
     EditableByProjectSteward      = projectCustomAttributeType.ProjectCustomAttributeTypeRoles.Any(x => x.ProjectCustomAttributeTypeRolePermissionType == ProjectCustomAttributeTypeRolePermissionType.Edit && x.RoleID == ProjectFirmaModels.Models.Role.ProjectSteward.RoleID);
     ViewableByUnassigned          = projectCustomAttributeType.ProjectCustomAttributeTypeRoles.Any(x => x.ProjectCustomAttributeTypeRolePermissionType == ProjectCustomAttributeTypeRolePermissionType.View && x.RoleID == ProjectFirmaModels.Models.Role.Unassigned.RoleID);
     ViewableByNormal              = projectCustomAttributeType.ProjectCustomAttributeTypeRoles.Any(x => x.ProjectCustomAttributeTypeRolePermissionType == ProjectCustomAttributeTypeRolePermissionType.View && x.RoleID == ProjectFirmaModels.Models.Role.Normal.RoleID);
     ViewableByProjectSteward      = projectCustomAttributeType.ProjectCustomAttributeTypeRoles.Any(x => x.ProjectCustomAttributeTypeRolePermissionType == ProjectCustomAttributeTypeRolePermissionType.View && x.RoleID == ProjectFirmaModels.Models.Role.ProjectSteward.RoleID);
     ViewableByAnonymous           = projectCustomAttributeType.ProjectCustomAttributeTypeRoles.Any(x => x.ProjectCustomAttributeTypeRolePermissionType == ProjectCustomAttributeTypeRolePermissionType.View && x.RoleID == null);
     IsViewableOnFactSheet         = projectCustomAttributeType.IsViewableOnFactSheet;
     ProjectCustomAttributeGroupID = projectCustomAttributeType.ProjectCustomAttributeGroupID;
 }
Example #4
0
        private static decimal?TryParseDecimalCustomAttributeValue(ProjectFirmaModels.Models.Project project, ProjectFirmaModels.Models.ProjectCustomAttributeType projectCustomAttributeType, Dictionary <int, List <vProjectCustomAttributeValue> > projectCustomAttributeDictionary)
        {
            if (Decimal.TryParse(project.GetProjectCustomAttributesValue(projectCustomAttributeType, projectCustomAttributeDictionary).ToString(), out var value))
            {
                return(value);
            }

            if (projectCustomAttributeType.ProjectCustomAttributeGroup.ProjectCustomAttributeGroupProjectCategories.All(x => x.ProjectCategoryID != project.ProjectCategoryID))
            {
                return(null);
            }
            return(0);
        }
Example #5
0
 /// <summary>
 /// Creates a "blank" object of this type and populates primitives with defaults
 /// </summary>
 public static ProjectCustomAttribute CreateNewBlank(Project project, ProjectCustomAttributeType projectCustomAttributeType)
 {
     return(new ProjectCustomAttribute(project, projectCustomAttributeType));
 }
Example #6
0
        public void UpdateModel(ProjectFirmaModels.Models.ProjectCustomAttributeType projectCustomAttributeType, FirmaSession currentFirmaSession)
        {
            projectCustomAttributeType.ProjectCustomAttributeTypeName   = ProjectCustomAttributeTypeName;
            projectCustomAttributeType.ProjectCustomAttributeDataTypeID = ProjectCustomAttributeDataTypeID ?? ModelObjectHelpers.NotYetAssignedID;
            projectCustomAttributeType.MeasurementUnitTypeID            = MeasurementUnitTypeID;
            projectCustomAttributeType.IsRequired = IsRequired.GetValueOrDefault();
            projectCustomAttributeType.ProjectCustomAttributeTypeDescription = ProjectCustomAttributeTypeDesription;
            projectCustomAttributeType.IsViewableOnFactSheet         = IsViewableOnFactSheet.GetValueOrDefault();
            projectCustomAttributeType.ProjectCustomAttributeGroupID = ProjectCustomAttributeGroupID;

            var projectCustomAttributeDataType = ProjectCustomAttributeDataTypeID != null
                ? ProjectCustomAttributeDataType.AllLookupDictionary[ProjectCustomAttributeDataTypeID.Value]
                : null;

            if (projectCustomAttributeDataType != null && projectCustomAttributeDataType.HasOptions())
            {
                projectCustomAttributeType.ProjectCustomAttributeTypeOptionsSchema = ProjectCustomAttributeTypeOptionsSchema;
            }
            else
            {
                projectCustomAttributeType.ProjectCustomAttributeTypeOptionsSchema = null;
            }

            var newProjectCustomAttributeTypeRoles = new List <ProjectCustomAttributeTypeRole>();

            if (EditableByNormal)
            {
                newProjectCustomAttributeTypeRoles.Add(new ProjectCustomAttributeTypeRole(projectCustomAttributeType.ProjectCustomAttributeTypeID, ProjectCustomAttributeTypeRolePermissionType.Edit.ProjectCustomAttributeTypeRolePermissionTypeID)
                {
                    RoleID = ProjectFirmaModels.Models.Role.Normal.RoleID
                });
            }
            if (EditableByProjectSteward)
            {
                newProjectCustomAttributeTypeRoles.Add(new ProjectCustomAttributeTypeRole(projectCustomAttributeType.ProjectCustomAttributeTypeID, ProjectCustomAttributeTypeRolePermissionType.Edit.ProjectCustomAttributeTypeRolePermissionTypeID)
                {
                    RoleID = ProjectFirmaModels.Models.Role.ProjectSteward.RoleID
                });
            }
            if (ViewableByUnassigned)
            {
                newProjectCustomAttributeTypeRoles.Add(new ProjectCustomAttributeTypeRole(projectCustomAttributeType.ProjectCustomAttributeTypeID, ProjectCustomAttributeTypeRolePermissionType.View.ProjectCustomAttributeTypeRolePermissionTypeID)
                {
                    RoleID = ProjectFirmaModels.Models.Role.Unassigned.RoleID
                });
            }
            if (ViewableByNormal)
            {
                newProjectCustomAttributeTypeRoles.Add(new ProjectCustomAttributeTypeRole(projectCustomAttributeType.ProjectCustomAttributeTypeID, ProjectCustomAttributeTypeRolePermissionType.View.ProjectCustomAttributeTypeRolePermissionTypeID)
                {
                    RoleID = ProjectFirmaModels.Models.Role.Normal.RoleID
                });
            }
            if (ViewableByProjectSteward)
            {
                newProjectCustomAttributeTypeRoles.Add(new ProjectCustomAttributeTypeRole(projectCustomAttributeType.ProjectCustomAttributeTypeID, ProjectCustomAttributeTypeRolePermissionType.View.ProjectCustomAttributeTypeRolePermissionTypeID)
                {
                    RoleID = ProjectFirmaModels.Models.Role.ProjectSteward.RoleID
                });
            }

            if (ViewableByAnonymous)
            {
                newProjectCustomAttributeTypeRoles.Add(new ProjectCustomAttributeTypeRole(projectCustomAttributeType.ProjectCustomAttributeTypeID, ProjectCustomAttributeTypeRolePermissionType.View.ProjectCustomAttributeTypeRolePermissionTypeID));
            }

            projectCustomAttributeType.ProjectCustomAttributeTypeRoles.Merge(newProjectCustomAttributeTypeRoles,
                                                                             HttpRequestStorage.DatabaseEntities.AllProjectCustomAttributeTypeRoles.Local,
                                                                             (x, y) => x.ProjectCustomAttributeTypeID == y.ProjectCustomAttributeTypeID && x.RoleID == y.RoleID &&
                                                                             x.ProjectCustomAttributeTypeRolePermissionTypeID ==
                                                                             y.ProjectCustomAttributeTypeRolePermissionTypeID, HttpRequestStorage.DatabaseEntities);
        }
Example #7
0
 /// <summary>
 /// Creates a "blank" object of this type and populates primitives with defaults
 /// </summary>
 public static ProjectCustomAttributeUpdate CreateNewBlank(ProjectUpdateBatch projectUpdateBatch, ProjectCustomAttributeType projectCustomAttributeType)
 {
     return(new ProjectCustomAttributeUpdate(projectUpdateBatch, projectCustomAttributeType));
 }
 /// <summary>
 /// Creates a "blank" object of this type and populates primitives with defaults
 /// </summary>
 public static ProjectCustomAttributeTypeRole CreateNewBlank(ProjectCustomAttributeType projectCustomAttributeType, ProjectCustomAttributeTypeRolePermissionType projectCustomAttributeTypeRolePermissionType)
 {
     return(new ProjectCustomAttributeTypeRole(projectCustomAttributeType, projectCustomAttributeTypeRolePermissionType));
 }