public static ComboTreeNode ToComboTreeNode(this TaxonomyLeaf taxonomyLeaf)
        {
            var key           = $"{TaxonomyLevel.Leaf.TaxonomyLevelID}-{taxonomyLeaf.TaxonomyLeafID}";
            var comboTreeNode = new ComboTreeNode(taxonomyLeaf.GetDisplayName(), key);

            return(comboTreeNode);
        }
Exemple #2
0
            public static TaxonomyLeaf Create()
            {
                var taxonomyBranch = TestTaxonomyBranch.Create();
                var taxonomyLeaf   = TaxonomyLeaf.CreateNewBlank(taxonomyBranch);

                return(taxonomyLeaf);
            }
 public static string GetTaxonomyBranchCodeAndName(this TaxonomyLeaf taxonomyLeaf)
 {
     if (taxonomyLeaf.TaxonomyBranch.TaxonomyBranchCode != null)
     {
         return(taxonomyLeaf.TaxonomyBranch.TaxonomyBranchCode + ": " + taxonomyLeaf.TaxonomyBranch.TaxonomyBranchName);
     }
     return(taxonomyLeaf.TaxonomyBranch.TaxonomyBranchName);
 }
 public static List <Project> GetAssociatedPrimaryAndSecondaryProjects(this TaxonomyLeaf taxonomyLeaf, FirmaSession currentFirmaSession)
 {
     return(taxonomyLeaf.Projects
            .Union(taxonomyLeaf.SecondaryProjectTaxonomyLeafs.Select(x => x.Project))
            .Distinct(new HavePrimaryKeyComparer <Project>())
            .ToList()
            .GetActiveProjectsAndProposals(currentFirmaSession.CanViewProposals()));
 }
Exemple #5
0
            /// <summary>
            /// Create new TaxonomyLeaf and attach it to the given context
            /// </summary>
            public static TaxonomyLeaf Create(DatabaseEntities dbContext)
            {
                var taxonomyBranch  = TestTaxonomyBranch.Create(dbContext);
                var taxonomyLeaf    = new TaxonomyLeaf(taxonomyBranch, MakeTestName("Test Taxonomy Tier One", TaxonomyLeaf.FieldLengths.TaxonomyLeafName));
                var newTaxonomyLeaf = taxonomyLeaf;

                dbContext.AllTaxonomyLeafs.Add(newTaxonomyLeaf);
                return(newTaxonomyLeaf);
            }
 public MatchmakerTaxonomyTier(TaxonomyLeaf taxonomyLeaf)
 {
     TaxonomyTierID       = taxonomyLeaf.TaxonomyLeafID;
     DisplayName          = taxonomyLeaf.GetDisplayName();
     SortOrder            = taxonomyLeaf.TaxonomyLeafSortOrder;
     Children             = null;
     TaxonomyLevel        = TaxonomyLevelEnum.Leaf;
     TaxonomyLeaf         = taxonomyLeaf;
     TaxonomyBranch       = null;
     TaxonomyTrunk        = null;
     MaximumChildrenCount = 0;
 }
        public static FancyTreeNode ToFancyTreeNode(this TaxonomyLeaf taxonomyLeaf, FirmaSession currentFirmaSession)
        {
            var fancyTreeNode = new FancyTreeNode($"{UrlTemplate.MakeHrefString(taxonomyLeaf.GetDetailUrl(), taxonomyLeaf.GetDisplayName())}",
                                                  taxonomyLeaf.TaxonomyLeafID.ToString(), false)
            {
                ThemeColor = String.IsNullOrWhiteSpace(taxonomyLeaf.ThemeColor) ? taxonomyLeaf.TaxonomyBranch.ThemeColor : taxonomyLeaf.ThemeColor,
                MapUrl     = GetCustomizedMapUrl(taxonomyLeaf),
                Children   = taxonomyLeaf.GetAssociatedProjects(currentFirmaSession).Select(x => x.ToFancyTreeNode(currentFirmaSession)).OrderBy(x => x.Title).ToList()
            };

            return(fancyTreeNode);
        }
Exemple #8
0
 public TaxonomyTier(TaxonomyLeaf taxonomyLeaf)
 {
     TaxonomyTierID   = taxonomyLeaf.TaxonomyLeafID;
     ThemeColor       = taxonomyLeaf.ThemeColor;
     DisplayName      = taxonomyLeaf.GetDisplayName();
     DisplayNameAsUrl = taxonomyLeaf.GetDisplayNameAsUrl();
     DetailUrl        = taxonomyLeaf.GetDetailUrl();
     TaxonomyTierPerformanceMeasures = taxonomyLeaf.GetTaxonomyTierPerformanceMeasures();
     SortOrder      = taxonomyLeaf.TaxonomyLeafSortOrder;
     TaxonomyLevel  = TaxonomyLevelEnum.Leaf;
     TaxonomyLeaf   = taxonomyLeaf;
     TaxonomyBranch = null;
     TaxonomyTrunk  = null;
 }
Exemple #9
0
        private PartialViewResult ViewDeleteTaxonomyLeaf(TaxonomyLeaf taxonomyLeaf,
                                                         ConfirmDialogFormViewModel viewModel)
        {
            var canDelete = !taxonomyLeaf.HasDependentObjects() &&
                            HttpRequestStorage.DatabaseEntities.TaxonomyLeafs.Count() > 1;
            var taxonomyLeafDisplayName = FieldDefinitionEnum.TaxonomyLeaf.ToType().GetFieldDefinitionLabel();
            var confirmMessage          = canDelete
                ? string.Format("Are you sure you want to delete this {0} '{1}'?", taxonomyLeafDisplayName,
                                taxonomyLeaf.GetDisplayName())
                : ConfirmDialogFormViewData.GetStandardCannotDeleteMessage(taxonomyLeafDisplayName,
                                                                           SitkaRoute <TaxonomyLeafController> .BuildLinkFromExpression(x => x.Detail(taxonomyLeaf), "here"));

            var viewData = new ConfirmDialogFormViewData(confirmMessage, canDelete);

            return(RazorPartialView <ConfirmDialogForm, ConfirmDialogFormViewData, ConfirmDialogFormViewModel>(viewData,
                                                                                                               viewModel));
        }
        public string GetDisplayNameAsDetailUrl()
        {
            switch (TaxonomyLevel)
            {
            case TaxonomyLevelEnum.Trunk:
                return($"{UrlTemplate.MakeHrefString(TaxonomyTrunk.GetDetailUrl(), GetDisplayName())}");

            case TaxonomyLevelEnum.Branch:
                return($"{UrlTemplate.MakeHrefString(TaxonomyBranch.GetDetailUrl(), GetDisplayName())}");

            case TaxonomyLevelEnum.Leaf:
                return($"{UrlTemplate.MakeHrefString(TaxonomyLeaf.GetDetailUrl(), GetDisplayName())}");

            default:
                return(string.Empty);
            }
        }
Exemple #11
0
        public FancyTreeNode ToFancyTreeNode(FirmaSession currentFirmaSession)
        {
            switch (TaxonomyLevel)
            {
            case TaxonomyLevelEnum.Leaf:
                return(TaxonomyLeaf.ToFancyTreeNode(currentFirmaSession));

            case TaxonomyLevelEnum.Branch:
                return(TaxonomyBranch.ToFancyTreeNode(currentFirmaSession));

            case TaxonomyLevelEnum.Trunk:
                return(TaxonomyTrunk.ToFancyTreeNode(currentFirmaSession));

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Exemple #12
0
        public ComboTreeNode ToComboTreeNode()
        {
            switch (TaxonomyLevel)
            {
            case TaxonomyLevelEnum.Leaf:
                return(TaxonomyLeaf.ToComboTreeNode());

            case TaxonomyLevelEnum.Branch:
                return(TaxonomyBranch.ToComboTreeNode());

            case TaxonomyLevelEnum.Trunk:
                return(TaxonomyTrunk.ToComboTreeNode());

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Exemple #13
0
        public ActionResult New(EditViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(ViewNew(viewModel));
            }

            var taxonomyLeaf = new TaxonomyLeaf(viewModel.TaxonomyBranchID, string.Empty);

            viewModel.UpdateModel(taxonomyLeaf, CurrentFirmaSession);
            HttpRequestStorage.DatabaseEntities.AllTaxonomyLeafs.Add(taxonomyLeaf);
            HttpRequestStorage.DatabaseEntities.SaveChanges();

            // we need to add this new leaf as a TaxonomyLeafPerformanceMeasure record if it's branch or trunk are currently associated to a PM
            var associatePerformanceMeasureTaxonomyLevel = MultiTenantHelpers.GetAssociatePerformanceMeasureTaxonomyLevel();

            if (associatePerformanceMeasureTaxonomyLevel == TaxonomyLevel.Branch)
            {
                var leaves =
                    HttpRequestStorage.DatabaseEntities.TaxonomyLeafs.Where(x =>
                                                                            x.TaxonomyBranchID == taxonomyLeaf.TaxonomyBranchID).Select(x => x.TaxonomyLeafID).ToList();
                var taxonomyLeafPerformanceMeasuresGroupedByPerformanceMeasure = HttpRequestStorage.DatabaseEntities.TaxonomyLeafPerformanceMeasures
                                                                                 .Where(x => leaves.Contains(x.TaxonomyLeafID)).ToList().GroupBy(x => x.PerformanceMeasure, new HavePrimaryKeyComparer <PerformanceMeasure>());
                var taxonomyLeafPerformanceMeasures = taxonomyLeafPerformanceMeasuresGroupedByPerformanceMeasure.Select(x =>
                                                                                                                        new TaxonomyLeafPerformanceMeasure(taxonomyLeaf, x.Key));
            }
            else if (associatePerformanceMeasureTaxonomyLevel == TaxonomyLevel.Trunk)
            {
                var taxonomyBranch = HttpRequestStorage.DatabaseEntities.TaxonomyBranches.GetTaxonomyBranch(taxonomyLeaf.TaxonomyBranchID);
                var leaves         = taxonomyBranch.TaxonomyTrunk.TaxonomyBranches.SelectMany(x => x.TaxonomyLeafs.Select(y => y.TaxonomyLeafID)).ToList();
                var taxonomyLeafPerformanceMeasuresGroupedByPerformanceMeasure = HttpRequestStorage.DatabaseEntities.TaxonomyLeafPerformanceMeasures
                                                                                 .Where(x => leaves.Contains(x.TaxonomyLeafID)).ToList().GroupBy(x => x.PerformanceMeasure, new HavePrimaryKeyComparer <PerformanceMeasure>());
                var taxonomyLeafPerformanceMeasures = taxonomyLeafPerformanceMeasuresGroupedByPerformanceMeasure.Select(x =>
                                                                                                                        new TaxonomyLeafPerformanceMeasure(taxonomyLeaf, x.Key));
            }
            SetMessageForDisplay($"New {FieldDefinitionEnum.TaxonomyLeaf.ToType().GetFieldDefinitionLabel()} {taxonomyLeaf.GetDisplayNameAsUrl()} successfully created!");
            return(new ModalDialogFormJsonResult());
        }
 public static List <Project> GetAssociatedProjects(this TaxonomyLeaf taxonomyLeaf, FirmaSession currentFirmaSession)
 {
     return(taxonomyLeaf.Projects.ToList().GetActiveProjectsAndProposals(currentFirmaSession.CanViewProposals()));
 }
 public static string GetDeleteUrl(this TaxonomyLeaf taxonomyLeaf)
 {
     return(DeleteUrlTemplate.ParameterReplace(taxonomyLeaf.TaxonomyLeafID));
 }
 public static HtmlString GetDisplayNameAsUrl(this TaxonomyLeaf taxonomyLeaf)
 {
     return(UrlTemplate.MakeHrefString(taxonomyLeaf.GetDetailUrl(), taxonomyLeaf.GetDisplayName()));
 }
Exemple #17
0
 public TaxonomyTierSimple(TaxonomyLeaf taxonomyLeaf) : this()
 {
     TaxonomyTierID   = taxonomyLeaf.TaxonomyLeafID;
     DisplayName      = taxonomyLeaf.GetDisplayName();
     ParentTaxonomyID = taxonomyLeaf.TaxonomyBranchID;
 }
 public static string GetCustomizedMapUrl(TaxonomyLeaf taxonomyLeaf) => ProjectMapCustomization.BuildCustomizedUrl(
     ProjectLocationFilterType.TaxonomyLeaf, taxonomyLeaf.TaxonomyLeafID.ToString(), ProjectColorByType.ProjectStage);
Exemple #19
0
            public static TaxonomyLeafPerformanceMeasure Create(TaxonomyLeaf taxonomyLeaf, PerformanceMeasure performanceMeasure)
            {
                var taxonomyLeafPerformanceMeasure = TaxonomyLeafPerformanceMeasure.CreateNewBlank(taxonomyLeaf, performanceMeasure);

                return(taxonomyLeafPerformanceMeasure);
            }