예제 #1
0
        public EditViewData(Person currentPerson,
                            IEnumerable <MeasurementUnitType> measurementUnitTypes,
                            List <ProjectCustomAttributeDataType> projectCustomAttributeDataTypes,
                            string submitUrl,
                            Models.FirmaPage instructionsFirmaPage,
                            Models.ProjectCustomAttributeType projectCustomAttributeType)
            : base(currentPerson)
        {
            EntityName = "Attribute Type";
            PageTitle  =
                $"{(projectCustomAttributeType != null ? "Edit" : "New")} Attribute Type";
            YesNos = BooleanFormats.GetYesNoSelectList();
            ProjectCustomAttributeDataTypes = projectCustomAttributeDataTypes.ToSelectListWithEmptyFirstRow(
                x => x.ProjectCustomAttributeDataTypeID.ToString(), x => x.ProjectCustomAttributeDataTypeDisplayName);
            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, currentPerson);

            ViewDataForAngular = new EditViewDataForAngular(projectCustomAttributeDataTypes);
        }
예제 #2
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;
            }
        }
예제 #3
0
 public EditViewModel(Models.ProjectCustomAttributeType projectCustomAttributeType, List <ProjectTypeJson> projectTypeJsonList)
 {
     ProjectCustomAttributeTypeID            = projectCustomAttributeType.ProjectCustomAttributeTypeID;
     ProjectCustomAttributeTypeName          = projectCustomAttributeType.ProjectCustomAttributeTypeName;
     ProjectCustomAttributeDataTypeID        = projectCustomAttributeType.ProjectCustomAttributeDataTypeID;
     MeasurementUnitTypeID                   = projectCustomAttributeType.MeasurementUnitTypeID;
     ProjectCustomAttributeTypeOptionsSchema = projectCustomAttributeType.ProjectCustomAttributeTypeOptionsSchema;
     IsRequired = projectCustomAttributeType.IsRequired;
     ProjectCustomAttributeTypeDesription = projectCustomAttributeType.ProjectCustomAttributeTypeDescription;
     ApplyToAllProjectTypes = projectCustomAttributeType.ApplyToAllProjectTypes;
     ProjectTypeJsonList    = projectTypeJsonList;
 }
        public DetailViewData(Person currentPerson,
                              Models.ProjectCustomAttributeType projectCustomAttributeType) : base(currentPerson)
        {
            ProjectCustomAttributeType = projectCustomAttributeType;
            EntityName = Models.FieldDefinition.ProjectCustomAttribute.GetFieldDefinitionLabelPluralized();
            PageTitle  = projectCustomAttributeType.ProjectCustomAttributeTypeName;
            ManageUrl  = SitkaRoute <ProjectCustomAttributeTypeController> .BuildUrlFromExpression(c => c.Manage());

            UserHasProjectCustomAttributeTypeManagePermissions = new FirmaAdminFeature().HasPermissionByPerson(currentPerson);

            ProjectTypeGridName    = "projectTypeGridForAttribute";
            ProjectTypeGridDataUrl = "#";
        }