コード例 #1
0
        public ActionResult ConfigureAccomplishmentsDashboard(ConfigureAccomplishmentsDashboardViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(ViewConfigureAccomplishmentsDashboard(viewModel));
            }

            var organizationRelationshipTypes = HttpRequestStorage.DatabaseEntities.OrganizationRelationshipTypes;

            viewModel.UpdateModel(organizationRelationshipTypes);
            MultiTenantHelpers.ClearTenantAttributeCacheForAllTenants();
            return(new ModalDialogFormJsonResult());
        }
コード例 #2
0
        public ActionResult EditBoundingBox(EditBoundingBoxViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                var tenant          = HttpRequestStorage.Tenant;
                var tenantAttribute = MultiTenantHelpers.GetTenantAttributeFromCache();
                return(ViewEditBoundingBox(viewModel, tenantAttribute));
            }

            viewModel.UpdateModel();
            MultiTenantHelpers.ClearTenantAttributeCacheForAllTenants();
            return(new ModalDialogFormJsonResult());
        }
コード例 #3
0
        public ActionResult EditTenantLogo(EditTenantLogoViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(ViewEditTenantLogo(viewModel));
            }

            var tenantAttribute = HttpRequestStorage.DatabaseEntities.AllTenantAttributes.Single(a => a.TenantID == viewModel.TenantID);

            viewModel.UpdateModel(tenantAttribute, CurrentFirmaSession, HttpRequestStorage.DatabaseEntities);
            MultiTenantHelpers.ClearTenantAttributeCacheForAllTenants();
            return(new ModalDialogFormJsonResult(new SitkaRoute <TenantController>(c => c.Detail()).BuildUrlFromExpression()));
        }
コード例 #4
0
        public ActionResult EditClassificationSystems(EditClassificationSystemsViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(ViewEditClassificationSystems(viewModel));
            }

            var currentClassificationSystems = MultiTenantHelpers.GetClassificationSystems();
            var allClassificationSystems     = HttpRequestStorage.DatabaseEntities.AllClassificationSystems.Local;

            viewModel.UpdateModel(CurrentFirmaSession, currentClassificationSystems, allClassificationSystems);
            MultiTenantHelpers.ClearTenantAttributeCacheForAllTenants();
            return(new ModalDialogFormJsonResult(new SitkaRoute <TenantController>(c => c.Detail()).BuildUrlFromExpression()));
        }
コード例 #5
0
        public ActionResult DeleteTenantStyleSheetFileResource(ConfirmDialogFormViewModel viewModel)
        {
            var tenantAttribute = HttpRequestStorage.DatabaseEntities.AllTenantAttributes.Single(a => a.TenantID == HttpRequestStorage.DatabaseEntities.TenantID);

            if (!ModelState.IsValid)
            {
                return(ViewDeleteTenantStyleSheetFileResource(viewModel, tenantAttribute));
            }

            var tenantAttributeTenantStyleSheetFileResource = tenantAttribute.TenantStyleSheetFileResourceInfo;
            var fileResourceDatas = tenantAttribute.TenantStyleSheetFileResourceInfo.FileResourceDatas;

            tenantAttribute.TenantStyleSheetFileResourceInfo.FileResourceDatas = null;
            tenantAttribute.TenantStyleSheetFileResourceInfo = null;
            foreach (var fileResourceData in fileResourceDatas)
            {
                fileResourceData.Delete(HttpRequestStorage.DatabaseEntities);
            }
            tenantAttributeTenantStyleSheetFileResource.Delete(HttpRequestStorage.DatabaseEntities);
            MultiTenantHelpers.ClearTenantAttributeCacheForAllTenants();
            return(new ModalDialogFormJsonResult());
        }
コード例 #6
0
        public ActionResult EditBasics(EditBasicsViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(ViewEditBasics(viewModel));
            }

            var tenantAttribute = HttpRequestStorage.DatabaseEntities.AllTenantAttributes.Single(a => a.TenantID == viewModel.TenantID);
            var oldTenantAttributeTaxonomyLevel = tenantAttribute.TaxonomyLevel;
            var oldTenantAttributeAssociatePerformanceMeasureTaxonomyLevelID = tenantAttribute.AssociatePerfomanceMeasureTaxonomyLevelID;

            viewModel.UpdateModel(tenantAttribute, CurrentFirmaSession);
            if (viewModel.BudgetTypeID == BudgetType.AnnualBudgetByCostType.BudgetTypeID)
            {
                var existingCostTypes = HttpRequestStorage.DatabaseEntities.CostTypes.ToList();
                var allCostTypes      = HttpRequestStorage.DatabaseEntities.AllCostTypes.Local;

                viewModel.UpdateCostTypes(existingCostTypes, allCostTypes);
            }
            var clearOutTaxonomyLeafPerformanceMeasures = oldTenantAttributeTaxonomyLevel.TaxonomyLevelID != tenantAttribute.TaxonomyLevelID || oldTenantAttributeAssociatePerformanceMeasureTaxonomyLevelID != tenantAttribute.AssociatePerfomanceMeasureTaxonomyLevelID;

            if (clearOutTaxonomyLeafPerformanceMeasures)
            {
                var taxonomyLeafPerformanceMeasures = HttpRequestStorage.DatabaseEntities.TaxonomyLeafPerformanceMeasures.ToList();
                foreach (var taxonomyLeafPerformanceMeasure in taxonomyLeafPerformanceMeasures)
                {
                    taxonomyLeafPerformanceMeasure.DeleteFull(HttpRequestStorage.DatabaseEntities);
                }
            }

            // if we are shrinking the number of tiers, we need to collapse child records to hidden parent record(s) named "Default"
            if (oldTenantAttributeTaxonomyLevel.TaxonomyLevelID > tenantAttribute.TaxonomyLevelID)
            {
                var          newTaxonomyLevel         = TaxonomyLevel.ToType(tenantAttribute.TaxonomyLevelID);
                const string defaultTrunkOrBranchName = "Default";
                if (newTaxonomyLevel == TaxonomyLevel.Branch)
                {
                    // create a new "Default" trunk to move all branches to
                    // ensure that name does not already exist
                    var newTaxonomyTrunkDefault = HttpRequestStorage.DatabaseEntities.TaxonomyTrunks.SingleOrDefault(x =>
                                                                                                                     x.TaxonomyTrunkName == defaultTrunkOrBranchName) ?? new TaxonomyTrunk(defaultTrunkOrBranchName);

                    var taxonomyBranches = HttpRequestStorage.DatabaseEntities.TaxonomyBranches.ToList();
                    foreach (var taxonomyBranch in taxonomyBranches)
                    {
                        taxonomyBranch.TaxonomyTrunk = newTaxonomyTrunkDefault;
                    }
                    HttpRequestStorage.DatabaseEntities.SaveChanges();
                    var taxonomyTrunks = HttpRequestStorage.DatabaseEntities.TaxonomyTrunks.Where(x => x.TaxonomyTrunkID != newTaxonomyTrunkDefault.TaxonomyTrunkID).ToList();
                    foreach (var taxonomyTrunk in taxonomyTrunks)
                    {
                        taxonomyTrunk.DeleteFull(HttpRequestStorage.DatabaseEntities);
                    }
                }
                else if (newTaxonomyLevel == TaxonomyLevel.Leaf)
                {
                    var newTaxonomyTrunkDefault = HttpRequestStorage.DatabaseEntities.TaxonomyTrunks.SingleOrDefault(x =>
                                                                                                                     x.TaxonomyTrunkName == defaultTrunkOrBranchName) ?? new TaxonomyTrunk(defaultTrunkOrBranchName);
                    var newTaxonomyBranchDefault = HttpRequestStorage.DatabaseEntities.TaxonomyBranches.SingleOrDefault(x =>
                                                                                                                        x.TaxonomyBranchName == defaultTrunkOrBranchName) ?? new TaxonomyBranch(newTaxonomyTrunkDefault, defaultTrunkOrBranchName);
                    var taxonomyLeaves = HttpRequestStorage.DatabaseEntities.TaxonomyLeafs.ToList();
                    foreach (var taxonomyLeaf in taxonomyLeaves)
                    {
                        taxonomyLeaf.TaxonomyBranch = newTaxonomyBranchDefault;
                    }
                    HttpRequestStorage.DatabaseEntities.SaveChanges();
                    var taxonomyBranches = HttpRequestStorage.DatabaseEntities.TaxonomyBranches.Where(x => x.TaxonomyBranchID != newTaxonomyBranchDefault.TaxonomyBranchID).ToList();
                    foreach (var taxonomyBranch in taxonomyBranches)
                    {
                        taxonomyBranch.DeleteFull(HttpRequestStorage.DatabaseEntities);
                    }

                    var taxonomyTrunks = HttpRequestStorage.DatabaseEntities.TaxonomyTrunks.Where(x => x.TaxonomyTrunkID != newTaxonomyTrunkDefault.TaxonomyTrunkID).ToList();
                    foreach (var taxonomyTrunk in taxonomyTrunks)
                    {
                        taxonomyTrunk.DeleteFull(HttpRequestStorage.DatabaseEntities);
                    }
                }
            }

            MultiTenantHelpers.ClearTenantAttributeCacheForAllTenants();

            return(new ModalDialogFormJsonResult(new SitkaRoute <TenantController>(c => c.Detail()).BuildUrlFromExpression()));
        }