Пример #1
0
        public EditViewData(FirmaSession currentFirmaSession,
                            IEnumerable <MeasurementUnitType> measurementUnitTypes,
                            List <FundingSourceCustomAttributeDataType> fundingSourceCustomAttributeDataTypes,
                            List <ProjectFirmaModels.Models.Role> roles,
                            string submitUrl,
                            ProjectFirmaModels.Models.FirmaPage instructionsFirmaPage,
                            ProjectFirmaModels.Models.FundingSourceCustomAttributeType fundingSourceCustomAttributeType)
            : base(currentFirmaSession)
        {
            EntityName = "Attribute Type";
            PageTitle  =
                $"{(fundingSourceCustomAttributeType != null ? "Edit" : "New")} Attribute Type";
            YesNos = BooleanFormats.GetYesNoSelectList();
            FundingSourceCustomAttributeDataTypes = fundingSourceCustomAttributeDataTypes.ToSelectListWithEmptyFirstRow(
                x => x.FundingSourceCustomAttributeDataTypeID.ToString(), x => x.FundingSourceCustomAttributeDataTypeDisplayName);
            MeasurementUnitTypes = measurementUnitTypes.OrderBy(x => x.MeasurementUnitTypeDisplayName)
                                   .ToSelectListWithEmptyFirstRow(
                x => x.MeasurementUnitTypeID.ToString(), x => x.MeasurementUnitTypeDisplayName,
                ViewUtilities.NoneString);
            FundingSourceCustomAttributeTypeIndexUrl =
                SitkaRoute <FundingSourceCustomAttributeTypeController> .BuildUrlFromExpression(x => x.Manage());

            SubmitUrl = submitUrl;

            ViewInstructionsFirmaPage = new ViewPageContentViewData(instructionsFirmaPage, currentFirmaSession);

            ViewDataForAngular = new EditViewDataForAngular(fundingSourceCustomAttributeDataTypes);
        }
 /// <summary>
 /// Constructor for building a new object with MinimalConstructor required fields, using objects whenever possible
 /// </summary>
 public FundingSourceCustomAttributeTypeRole(FundingSourceCustomAttributeType fundingSourceCustomAttributeType, Role role, FundingSourceCustomAttributeTypeRolePermissionType fundingSourceCustomAttributeTypeRolePermissionType) : this()
 {
     // Mark this as a new object by setting primary key with special value
     this.FundingSourceCustomAttributeTypeRoleID = ModelObjectHelpers.MakeNextUnsavedPrimaryKeyValue();
     this.FundingSourceCustomAttributeTypeID     = fundingSourceCustomAttributeType.FundingSourceCustomAttributeTypeID;
     this.FundingSourceCustomAttributeType       = fundingSourceCustomAttributeType;
     fundingSourceCustomAttributeType.FundingSourceCustomAttributeTypeRoles.Add(this);
     this.RoleID = role.RoleID;
     this.FundingSourceCustomAttributeTypeRolePermissionTypeID = fundingSourceCustomAttributeTypeRolePermissionType.FundingSourceCustomAttributeTypeRolePermissionTypeID;
 }
Пример #3
0
        public DetailViewData(FirmaSession currentFirmaSession,
                              ProjectFirmaModels.Models.FundingSourceCustomAttributeType fundingSourceCustomAttributeType) : base(currentFirmaSession)
        {
            FundingSourceCustomAttributeType = fundingSourceCustomAttributeType;
            EntityName = FieldDefinitionEnum.FundingSourceCustomAttribute.ToType().GetFieldDefinitionLabelPluralized();
            PageTitle  = fundingSourceCustomAttributeType.FundingSourceCustomAttributeTypeName;
            ManageUrl  = SitkaRoute <FundingSourceCustomAttributeTypeController> .BuildUrlFromExpression(c => c.Manage());

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

            ProjectTypeGridName    = "fundingSourceTypeGridForAttribute";
            ProjectTypeGridDataUrl = "#";
        }
Пример #4
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);
        }
Пример #5
0
 public EditViewModel(ProjectFirmaModels.Models.FundingSourceCustomAttributeType fundingSourceCustomAttributeType)
 {
     FundingSourceCustomAttributeTypeID     = fundingSourceCustomAttributeType.FundingSourceCustomAttributeTypeID;
     FundingSourceCustomAttributeTypeName   = fundingSourceCustomAttributeType.FundingSourceCustomAttributeTypeName;
     FundingSourceCustomAttributeDataTypeID = fundingSourceCustomAttributeType.FundingSourceCustomAttributeDataTypeID;
     MeasurementUnitTypeID = fundingSourceCustomAttributeType.MeasurementUnitTypeID;
     FundingSourceCustomAttributeTypeOptionsSchema = fundingSourceCustomAttributeType.FundingSourceCustomAttributeTypeOptionsSchema;
     IsRequired = fundingSourceCustomAttributeType.IsRequired;
     FundingSourceCustomAttributeTypeDesription    = fundingSourceCustomAttributeType.FundingSourceCustomAttributeTypeDescription;
     FundingSourceCustomAttributeIncludeInGridSpec = fundingSourceCustomAttributeType.IncludeInFundingSourceGrid;
     EditableByNormal         = fundingSourceCustomAttributeType.FundingSourceCustomAttributeTypeRoles.Any(x => x.FundingSourceCustomAttributeTypeRolePermissionType == FundingSourceCustomAttributeTypeRolePermissionType.Edit && x.RoleID == ProjectFirmaModels.Models.Role.Normal.RoleID);
     EditableByProjectSteward = fundingSourceCustomAttributeType.FundingSourceCustomAttributeTypeRoles.Any(x => x.FundingSourceCustomAttributeTypeRolePermissionType == FundingSourceCustomAttributeTypeRolePermissionType.Edit && x.RoleID == ProjectFirmaModels.Models.Role.ProjectSteward.RoleID);
     ViewableByUnassigned     = fundingSourceCustomAttributeType.FundingSourceCustomAttributeTypeRoles.Any(x => x.FundingSourceCustomAttributeTypeRolePermissionType == FundingSourceCustomAttributeTypeRolePermissionType.View && x.RoleID == ProjectFirmaModels.Models.Role.Unassigned.RoleID);
     ViewableByNormal         = fundingSourceCustomAttributeType.FundingSourceCustomAttributeTypeRoles.Any(x => x.FundingSourceCustomAttributeTypeRolePermissionType == FundingSourceCustomAttributeTypeRolePermissionType.View && x.RoleID == ProjectFirmaModels.Models.Role.Normal.RoleID);
     ViewableByProjectSteward = fundingSourceCustomAttributeType.FundingSourceCustomAttributeTypeRoles.Any(x => x.FundingSourceCustomAttributeTypeRolePermissionType == FundingSourceCustomAttributeTypeRolePermissionType.View && x.RoleID == ProjectFirmaModels.Models.Role.ProjectSteward.RoleID);
 }
 /// <summary>
 /// Creates a "blank" object of this type and populates primitives with defaults
 /// </summary>
 public static FundingSourceCustomAttributeTypeRole CreateNewBlank(FundingSourceCustomAttributeType fundingSourceCustomAttributeType, Role role, FundingSourceCustomAttributeTypeRolePermissionType fundingSourceCustomAttributeTypeRolePermissionType)
 {
     return(new FundingSourceCustomAttributeTypeRole(fundingSourceCustomAttributeType, role, fundingSourceCustomAttributeTypeRolePermissionType));
 }
 /// <summary>
 /// Creates a "blank" object of this type and populates primitives with defaults
 /// </summary>
 public static FundingSourceCustomAttribute CreateNewBlank(FundingSource fundingSource, FundingSourceCustomAttributeType fundingSourceCustomAttributeType)
 {
     return(new FundingSourceCustomAttribute(fundingSource, fundingSourceCustomAttributeType));
 }