예제 #1
0
        public void UpdateModel(Models.ProjectCustomAttributeType projectCustomAttributeType, Person currentPerson)
        {
            projectCustomAttributeType.ProjectCustomAttributeTypeName   = ProjectCustomAttributeTypeName;
            projectCustomAttributeType.ProjectCustomAttributeDataTypeID = ProjectCustomAttributeDataTypeID ?? ModelObjectHelpers.NotYetAssignedID;
            projectCustomAttributeType.MeasurementUnitTypeID            = MeasurementUnitTypeID;
            projectCustomAttributeType.IsRequired = IsRequired.GetValueOrDefault();
            projectCustomAttributeType.ProjectCustomAttributeTypeDescription = ProjectCustomAttributeTypeDesription;
            projectCustomAttributeType.ApplyToAllProjectTypes = ApplyToAllProjectTypes ?? false;

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

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

            var existingProjectTypeProjectCustomAttributeTypes =
                projectCustomAttributeType.ProjectTypeProjectCustomAttributeTypes.ToList();

            if (!projectCustomAttributeType.ApplyToAllProjectTypes)
            {
                foreach (var projectTypeJson in ProjectTypeJsonList)
                {
                    if (!projectTypeJson.Selected)
                    {
                        var existingToDelete =
                            existingProjectTypeProjectCustomAttributeTypes.SingleOrDefault(x =>
                                                                                           x.ProjectTypeID == projectTypeJson.ProjectTypeID);
                        if (existingToDelete != null)
                        {
                            existingProjectTypeProjectCustomAttributeTypes.Remove(existingToDelete);
                            existingToDelete.DeleteFull(HttpRequestStorage.DatabaseEntities);
                        }
                    }
                    if (projectTypeJson.Selected)
                    {
                        if (!existingProjectTypeProjectCustomAttributeTypes.Any(x =>
                                                                                x.ProjectTypeID == projectTypeJson.ProjectTypeID))
                        {
                            var projectTypeProjectCustomAttributeType = new ProjectTypeProjectCustomAttributeType(projectTypeJson.ProjectTypeID, projectCustomAttributeType.ProjectCustomAttributeTypeID);
                            existingProjectTypeProjectCustomAttributeTypes.Add(projectTypeProjectCustomAttributeType);
                        }
                    }
                }

                projectCustomAttributeType.ProjectTypeProjectCustomAttributeTypes =
                    existingProjectTypeProjectCustomAttributeTypes;
            }
            else
            {
                existingProjectTypeProjectCustomAttributeTypes.ForEach(x => x.DeleteFull(HttpRequestStorage.DatabaseEntities));
                projectCustomAttributeType.ProjectTypeProjectCustomAttributeTypes = null;
            }
        }
예제 #2
0
        public void UpdateModel(ProjectFirmaModels.Models.FundingSourceCustomAttributeType fundingSourceCustomAttributeType, FirmaSession currentFirmaSession)
        {
            fundingSourceCustomAttributeType.FundingSourceCustomAttributeTypeName   = FundingSourceCustomAttributeTypeName;
            fundingSourceCustomAttributeType.FundingSourceCustomAttributeDataTypeID = FundingSourceCustomAttributeDataTypeID ?? ModelObjectHelpers.NotYetAssignedID;
            fundingSourceCustomAttributeType.MeasurementUnitTypeID = MeasurementUnitTypeID;
            fundingSourceCustomAttributeType.IsRequired            = IsRequired.GetValueOrDefault();
            fundingSourceCustomAttributeType.FundingSourceCustomAttributeTypeDescription = FundingSourceCustomAttributeTypeDesription;
            fundingSourceCustomAttributeType.IncludeInFundingSourceGrid = FundingSourceCustomAttributeIncludeInGridSpec;

            var fundingSourceCustomAttributeDataType = FundingSourceCustomAttributeDataTypeID != null
                ? FundingSourceCustomAttributeDataType.AllLookupDictionary[FundingSourceCustomAttributeDataTypeID.Value]
                : null;

            if (fundingSourceCustomAttributeDataType != null && fundingSourceCustomAttributeDataType.HasOptions())
            {
                fundingSourceCustomAttributeType.FundingSourceCustomAttributeTypeOptionsSchema = FundingSourceCustomAttributeTypeOptionsSchema;
            }
            else
            {
                fundingSourceCustomAttributeType.FundingSourceCustomAttributeTypeOptionsSchema = null;
            }

            var newFundingSourceCustomAttributeTypeRoles = new List <FundingSourceCustomAttributeTypeRole>();

            if (this.EditableByNormal == true)
            {
                newFundingSourceCustomAttributeTypeRoles.Add(new FundingSourceCustomAttributeTypeRole(fundingSourceCustomAttributeType.FundingSourceCustomAttributeTypeID, ProjectFirmaModels.Models.Role.Normal.RoleID, FundingSourceCustomAttributeTypeRolePermissionType.Edit.FundingSourceCustomAttributeTypeRolePermissionTypeID));
            }
            if (this.EditableByProjectSteward == true)
            {
                newFundingSourceCustomAttributeTypeRoles.Add(new FundingSourceCustomAttributeTypeRole(fundingSourceCustomAttributeType.FundingSourceCustomAttributeTypeID, ProjectFirmaModels.Models.Role.ProjectSteward.RoleID, FundingSourceCustomAttributeTypeRolePermissionType.Edit.FundingSourceCustomAttributeTypeRolePermissionTypeID));
            }
            if (this.ViewableByUnassigned == true)
            {
                newFundingSourceCustomAttributeTypeRoles.Add(new FundingSourceCustomAttributeTypeRole(fundingSourceCustomAttributeType.FundingSourceCustomAttributeTypeID, ProjectFirmaModels.Models.Role.Unassigned.RoleID, FundingSourceCustomAttributeTypeRolePermissionType.View.FundingSourceCustomAttributeTypeRolePermissionTypeID));
            }
            if (this.ViewableByNormal == true)
            {
                newFundingSourceCustomAttributeTypeRoles.Add(new FundingSourceCustomAttributeTypeRole(fundingSourceCustomAttributeType.FundingSourceCustomAttributeTypeID, ProjectFirmaModels.Models.Role.Normal.RoleID, FundingSourceCustomAttributeTypeRolePermissionType.View.FundingSourceCustomAttributeTypeRolePermissionTypeID));
            }
            if (this.ViewableByProjectSteward == true)
            {
                newFundingSourceCustomAttributeTypeRoles.Add(new FundingSourceCustomAttributeTypeRole(fundingSourceCustomAttributeType.FundingSourceCustomAttributeTypeID, ProjectFirmaModels.Models.Role.ProjectSteward.RoleID, FundingSourceCustomAttributeTypeRolePermissionType.View.FundingSourceCustomAttributeTypeRolePermissionTypeID));
            }

            fundingSourceCustomAttributeType.FundingSourceCustomAttributeTypeRoles.Merge(newFundingSourceCustomAttributeTypeRoles,
                                                                                         HttpRequestStorage.DatabaseEntities.AllFundingSourceCustomAttributeTypeRoles.Local,
                                                                                         (x, y) => x.FundingSourceCustomAttributeTypeID == y.FundingSourceCustomAttributeTypeID && x.RoleID == y.RoleID &&
                                                                                         x.FundingSourceCustomAttributeTypeRolePermissionTypeID ==
                                                                                         y.FundingSourceCustomAttributeTypeRolePermissionTypeID, HttpRequestStorage.DatabaseEntities);
        }
예제 #3
0
        public void UpdateModel(Models.CustomAttributeType customAttributeType, Person currentPerson)
        {
            customAttributeType.CustomAttributeTypeName   = CustomAttributeTypeName;
            customAttributeType.CustomAttributeDataTypeID = CustomAttributeDataTypeID.Value;
            customAttributeType.MeasurementUnitTypeID     = MeasurementUnitTypeID;
            customAttributeType.IsRequired = IsRequired.GetValueOrDefault();
            customAttributeType.CustomAttributeTypePurposeID   = CustomAttributeTypePurposeID.GetValueOrDefault();
            customAttributeType.CustomAttributeTypeDescription = CustomAttributeTypeDesription;

            var customAttributeDataType = CustomAttributeDataType.AllLookupDictionary[CustomAttributeDataTypeID.Value];

            if (customAttributeDataType.HasOptions())
            {
                customAttributeType.CustomAttributeTypeOptionsSchema = CustomAttributeTypeOptionsSchema;
            }
            else
            {
                customAttributeType.CustomAttributeTypeOptionsSchema = null;
            }
        }
예제 #4
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);
        }