Exemplo n.º 1
0
        public ActionResult CostAuthorityDetail(string costAuthorityWorkBreakdownStructureString)
        {
            // If just a pure int, likely an OLD URL where we just took CostAuthorityID.
            if (int.TryParse(costAuthorityWorkBreakdownStructureString, out var possibleCostAuthorityID))
            {
                var possibleCostAuthority = HttpRequestStorage.DatabaseEntities.CostAuthorities.SingleOrDefault(ca => ca.CostAuthorityID == possibleCostAuthorityID);
                if (possibleCostAuthority != null)
                {
                    // We want this to be a permanent redirect since Google is the one hitting us with these old IDs.
                    return(RedirectToActionWithPermanentRedirect(new SitkaRoute <CostAuthorityController>(pc => pc.CostAuthorityDetail(possibleCostAuthority.CostAuthorityWorkBreakdownStructure))));
                }
            }

            string correctedCawbsString = CostAuthority.CorrectedCostAuthorityWorkBreakdownStructureString(costAuthorityWorkBreakdownStructureString);

            // If they did enter a CAWBS string we could fix, we redirect permanently in case they bookmark
            if (correctedCawbsString != costAuthorityWorkBreakdownStructureString)
            {
                return(RedirectToAction(new SitkaRoute <CostAuthorityController>(pc => pc.CostAuthorityDetail(correctedCawbsString))));
            }
            var costAuthority = HttpRequestStorage.DatabaseEntities.CostAuthorities.SingleOrDefault(ca => ca.CostAuthorityWorkBreakdownStructure == correctedCawbsString);

            Check.EnsureNotNull(costAuthority, $"Could not find Cost Authority with CostAuthorityWorkBreakdownStructure of {correctedCawbsString}");
            var viewData = new CostAuthorityDetailViewData(CurrentFirmaSession, costAuthority);

            return(RazorView <CostAuthorityDetail, CostAuthorityDetailViewData>(viewData));
        }
Exemplo n.º 2
0
 /// <summary>
 /// Constructor for building a new simple object with the POCO class
 /// </summary>
 public CostAuthoritySimple(CostAuthority costAuthority)
     : this()
 {
     CostAuthorityID = costAuthority.CostAuthorityID;
     CostAuthorityAgreementSimplesList = costAuthority.AgreementCostAuthorities.Select(x => new AgreementSimple(x.Agreement)).ToList();
     CostAuthorityDisplayName          = $"{costAuthority.CostAuthorityWorkBreakdownStructure} - {costAuthority.AccountStructureDescription}";
     CountOfRelatedAgreements          = CostAuthorityAgreementSimplesList.Count;
     CostAuthorityDropdownDisplayName  =
         $"{costAuthority.CostAuthorityWorkBreakdownStructure} - {costAuthority.AccountStructureDescription}{(CostAuthorityAgreementSimplesList.Any() ? GetRelatedAgreementIDsAsCommaDelimitedString() : "")}";
 }
Exemplo n.º 3
0
        /// <summary>
        /// Get the Projects associated with this Cost Authority through its associated agreements
        /// </summary>
        /// <param name="costAuthority"></param>
        /// <returns></returns>
        public static List <Project> GetAssociatedProjects(this CostAuthority costAuthority)
        {
            var projects = costAuthority.CostAuthorityProjects.Select(cap => cap.Project).ToList();

            return(projects);
        }
Exemplo n.º 4
0
 public static HtmlString GetDetailLinkUsingCostAuthorityWorkBreakdownStructure(this CostAuthority costAuthority)
 {
     return(new HtmlString(SitkaRoute <CostAuthorityController> .BuildLinkFromExpression(cac => cac.CostAuthorityDetail(costAuthority.CostAuthorityWorkBreakdownStructure), costAuthority.CostAuthorityWorkBreakdownStructure)));
 }
Exemplo n.º 5
0
 public static string GetDetailUrl(this CostAuthority costAuthority)
 {
     return(DetailUrlTemplate.ParameterReplace(costAuthority.CostAuthorityWorkBreakdownStructure));
 }
Exemplo n.º 6
0
 /// <summary>
 /// Convenience accessor for Reclamation Agreements.
 /// </summary>
 public static List <Agreement> GetReclamationAgreements(this CostAuthority costAuthority)
 {
     return(costAuthority.AgreementCostAuthorities.Select(rarca => rarca.Agreement).ToList());
 }
Exemplo n.º 7
0
 public static string GetDisplayName(this CostAuthority costAuthority)
 {
     return($"{costAuthority.CostAuthorityWorkBreakdownStructure}");
 }