public ObligationRequestDetailViewData(FirmaSession currentFirmaSession,
                                               ProjectFirmaModels.Models.ObligationRequest obligationRequest,
                                               bool userCanInteractWithSubmissionNotes,
                                               EntityNotesViewData obligationRequestNotesViewData) : base(currentFirmaSession)
        {
            PageTitle         = $"Obligation Request: {obligationRequest.GetObligationRequestNumber()}";
            EntityName        = "Obligation Request Detail";
            ObligationRequest = obligationRequest;
            IndexUrl          = SitkaRoute <ObligationRequestController> .BuildUrlFromExpression(c => c.ObligationRequestIndex());

            EditObligationRequestBasicsUrl = SitkaRoute <ObligationRequestController> .BuildUrlFromExpression(c => c.Edit(obligationRequest));

            EditRequisitionInformationUrl = SitkaRoute <ObligationRequestController> .BuildUrlFromExpression(c => c.EditRequisitionInformation(obligationRequest));

            UserCanEditObligationRequest       = new ObligationRequestCreateFeature().HasPermissionByFirmaSession(currentFirmaSession);
            UserCanEditRequisitionInformation  = new ObligationRequestCreateFeature().HasPermissionByFirmaSession(currentFirmaSession);
            UserCanInteractWithSubmissionNotes = userCanInteractWithSubmissionNotes;
            ObligationRequestNotesViewData     = obligationRequestNotesViewData;

            // Potential Matches
            PotentialMatches = obligationRequest.CostAuthorityObligationRequests
                               .SelectMany(x => x.CostAuthorityObligationRequestPotentialObligationNumberMatches).ToList();
            PotentialMatchesGridName    = "potentialMatchesGrid";
            PotentialMatchesGridSpec    = new CostAuthorityObligationRequestPotentialObligationNumberMatchGridSpec(currentFirmaSession);
            PotentialMatchesGridDataUrl = SitkaRoute <ObligationRequestController> .BuildUrlFromExpression(cac => cac.PotentialObligationRequestMatchesJsonData(obligationRequest));

            ShowPotentialMatches = obligationRequest.ObligationNumber == null &&
                                   obligationRequest.Agreement == null &&
                                   PotentialMatches.Any();

            var costAuthorityIDList = obligationRequest.Agreement != null
                ? obligationRequest.Agreement.AgreementCostAuthorities
                                      .Select(x => x.CostAuthorityID).ToList()
                : new List <int>();

            // Match Status
            MatchStatus = GetMatchStatus(obligationRequest, PotentialMatches);

            // Unmatch Dialog
            string unmatchUrl = SitkaRoute <ObligationRequestController> .BuildUrlFromExpression(x => x.ConfirmObligationRequestUnmatch(obligationRequest));

            var extraCssClassesForAButton = new List <string>()
            {
                "btn", "btn-sm", "btn-firma"
            };

            UnmatchObligationRequestButtonHtml =
                ModalDialogFormHelper.MakeConfirmDialogLink("Unmatch", unmatchUrl, "Unmatch Obligation Request", "Unmatch", extraCssClassesForAButton, true);

            CostAuthorityObligationRequestGridName = "costAuthorityObligationRequestGrid";
            CostAuthorityObligationRequestGridSpec = new CostAuthorityObligationRequestGridSpec(CurrentFirmaSession, obligationRequest.ObligationRequestStatus == ObligationRequestStatus.Draft, costAuthorityIDList)
            {
                ObjectNameSingular  = $"{FieldDefinitionEnum.CostAuthorityWorkBreakdownStructure.ToType().GetFieldDefinitionLabel()} associated with {FieldDefinitionEnum.ObligationRequest.ToType().GetFieldDefinitionLabel()} {obligationRequest.ObligationRequestID.ToString("D4")}",
                ObjectNamePlural    = $"{FieldDefinitionEnum.CostAuthorityWorkBreakdownStructure.ToType().GetFieldDefinitionLabelPluralized()} associated with {FieldDefinitionEnum.ObligationRequest.ToType().GetFieldDefinitionLabel()} {obligationRequest.ObligationRequestID.ToString("D4")}",
                SaveFiltersInCookie = true
            };
            CostAuthorityObligationRequestGridDataUrl = SitkaRoute <ObligationRequestController> .BuildUrlFromExpression(cac => cac.CostAuthorityObligationRequestsJsonData(obligationRequest));
        }
 public bool HasMatch(RoomNumber room)
 {
     return(PotentialMatches.Any(x => x.RoomNumber == room));
 }
 public Room GetMatch(RoomNumber room)
 {
     return(PotentialMatches.SingleOrDefault(x => x.RoomNumber == room));
 }