예제 #1
0
        public EditViewData(FirmaSession currentFirmaSession,
                            string submitUrl,
                            ProjectFirmaModels.Models.FirmaPage instructionsFirmaPage,
                            ProjectFirmaModels.Models.ProjectCustomAttributeGroup projectCustomAttributeGroup)
            : base(currentFirmaSession)
        {
            EntityName = "Attribute Group";
            PageTitle  =
                $"{(projectCustomAttributeGroup != null ? "Edit" : "New")} Attribute Group";
            ProjectCustomAttributeGroupIndexUrl =
                SitkaRoute <ProjectCustomAttributeGroupController> .BuildUrlFromExpression(x => x.Manage());

            SubmitUrl = submitUrl;

            ViewInstructionsFirmaPage  = new ViewPageContentViewData(instructionsFirmaPage, currentFirmaSession);
            TenantAttribute            = MultiTenantHelpers.GetTenantAttributeFromCache();
            ProjectTypeSelectListItems = ProjectCategory.All.ToSelectList(x => x.ProjectCategoryID.ToString(), x => x.ProjectCategoryDisplayName);

            if (projectCustomAttributeGroup != null && projectCustomAttributeGroup.ProjectCustomAttributeTypes.Any(x => x.ProjectCustomAttributes.Any(y => y.ProjectCustomAttributeValues.Any())))
            {
                HasExistingData = true;
            }
            else
            {
                HasExistingData = false;
            }
        }
 /// <summary>
 /// Constructor for building a new object with MinimalConstructor required fields, using objects whenever possible
 /// </summary>
 public ProjectCustomAttributeGroupProjectCategory(ProjectCustomAttributeGroup projectCustomAttributeGroup, ProjectCategory projectCategory) : this()
 {
     // Mark this as a new object by setting primary key with special value
     this.ProjectCustomAttributeGroupProjectCategoryID = ModelObjectHelpers.MakeNextUnsavedPrimaryKeyValue();
     this.ProjectCustomAttributeGroupID = projectCustomAttributeGroup.ProjectCustomAttributeGroupID;
     this.ProjectCustomAttributeGroup   = projectCustomAttributeGroup;
     projectCustomAttributeGroup.ProjectCustomAttributeGroupProjectCategories.Add(this);
     this.ProjectCategoryID = projectCategory.ProjectCategoryID;
 }
예제 #3
0
        public void UpdateModel(ProjectFirmaModels.Models.ProjectCustomAttributeGroup projectCustomAttributeGroup, FirmaSession currentFirmaSession)
        {
            projectCustomAttributeGroup.ProjectCustomAttributeGroupName = ProjectCustomAttributeGroupName;

            List <ProjectCustomAttributeGroupProjectCategory> updatedProjectCustomAttributeGroupProjectCategories = new List <ProjectCustomAttributeGroupProjectCategory>();

            foreach (var projectCategoryEnum in ProjectCategoryEnums)
            {
                var projectCustomAttributeGroupProjectType = HttpRequestStorage.DatabaseEntities.ProjectCustomAttributeGroupProjectCategories
                                                             .FirstOrDefault(x =>
                                                                             x.ProjectCategoryID == (int)projectCategoryEnum &&
                                                                             x.ProjectCustomAttributeGroupID == ProjectCustomAttributeGroupID);

                if (projectCustomAttributeGroupProjectType == null)
                {
                    projectCustomAttributeGroupProjectType = new ProjectCustomAttributeGroupProjectCategory(ProjectCustomAttributeGroupID, (int)projectCategoryEnum);
                }

                updatedProjectCustomAttributeGroupProjectCategories.Add(projectCustomAttributeGroupProjectType);
            }
            var allProjectCustomAttributeGroupProjectCategories = HttpRequestStorage.DatabaseEntities.AllProjectCustomAttributeGroupProjectCategories.Local;

            projectCustomAttributeGroup.ProjectCustomAttributeGroupProjectCategories.Merge(
                updatedProjectCustomAttributeGroupProjectCategories,
                allProjectCustomAttributeGroupProjectCategories,
                (x, y) => x.ProjectCustomAttributeGroupProjectCategoryID == y.ProjectCustomAttributeGroupProjectCategoryID, HttpRequestStorage.DatabaseEntities);


            if (projectCustomAttributeGroup.SortOrder != null)
            {
                return;
            }
            var allProjectCustomAttributeGroups = HttpRequestStorage.DatabaseEntities.ProjectCustomAttributeGroups;
            var maxSortOrder = allProjectCustomAttributeGroups.Select(x => x.SortOrder).Max();

            projectCustomAttributeGroup.SortOrder = maxSortOrder + EditSortOrderViewModel.SortOrderIncrement;
        }
예제 #4
0
 public EditViewModel(ProjectFirmaModels.Models.ProjectCustomAttributeGroup projectCustomAttributeGroup)
 {
     ProjectCustomAttributeGroupID   = projectCustomAttributeGroup.ProjectCustomAttributeGroupID;
     ProjectCustomAttributeGroupName = projectCustomAttributeGroup.ProjectCustomAttributeGroupName;
     ProjectCategoryEnums            = projectCustomAttributeGroup.ProjectCustomAttributeGroupProjectCategories.Select(x => x.ProjectCategory.ToEnum).ToList();
 }
 /// <summary>
 /// Creates a "blank" object of this type and populates primitives with defaults
 /// </summary>
 public static ProjectCustomAttributeGroupProjectCategory CreateNewBlank(ProjectCustomAttributeGroup projectCustomAttributeGroup, ProjectCategory projectCategory)
 {
     return(new ProjectCustomAttributeGroupProjectCategory(projectCustomAttributeGroup, projectCategory));
 }
예제 #6
0
 /// <summary>
 /// Creates a "blank" object of this type and populates primitives with defaults
 /// </summary>
 public static ProjectCustomAttributeType CreateNewBlank(ProjectCustomAttributeDataType projectCustomAttributeDataType, ProjectCustomAttributeGroup projectCustomAttributeGroup)
 {
     return(new ProjectCustomAttributeType(default(string), projectCustomAttributeDataType, default(bool), default(bool), projectCustomAttributeGroup));
 }
예제 #7
0
 /// <summary>
 /// Constructor for building a new object with MinimalConstructor required fields, using objects whenever possible
 /// </summary>
 public ProjectCustomAttributeType(string projectCustomAttributeTypeName, ProjectCustomAttributeDataType projectCustomAttributeDataType, bool isRequired, bool isViewableOnFactSheet, ProjectCustomAttributeGroup projectCustomAttributeGroup) : this()
 {
     // Mark this as a new object by setting primary key with special value
     this.ProjectCustomAttributeTypeID     = ModelObjectHelpers.MakeNextUnsavedPrimaryKeyValue();
     this.ProjectCustomAttributeTypeName   = projectCustomAttributeTypeName;
     this.ProjectCustomAttributeDataTypeID = projectCustomAttributeDataType.ProjectCustomAttributeDataTypeID;
     this.IsRequired                    = isRequired;
     this.IsViewableOnFactSheet         = isViewableOnFactSheet;
     this.ProjectCustomAttributeGroupID = projectCustomAttributeGroup.ProjectCustomAttributeGroupID;
     this.ProjectCustomAttributeGroup   = projectCustomAttributeGroup;
     projectCustomAttributeGroup.ProjectCustomAttributeTypes.Add(this);
 }