public ViewResult GrantAllocationAwardDetail(GrantAllocationAwardPrimaryKey grantAllocationAwardPrimaryKey)
        {
            var grantAllocationAward = grantAllocationAwardPrimaryKey.EntityObject;

            if (grantAllocationAward == null)
            {
                throw new Exception($"Could not find GrantAllocationAwardID # {grantAllocationAwardPrimaryKey.PrimaryKeyValue}; has it been deleted?");
            }

            var backButtonUrl = SitkaRoute <FocusAreaController> .BuildUrlFromExpression(x => x.Detail(grantAllocationAward.FocusAreaID));

            var backButtonText = $"Back to {FieldDefinition.FocusArea.GetFieldDefinitionLabel()}: {grantAllocationAward.FocusArea.FocusAreaName}";

            var suppliesLineItemGridSpec             = new SuppliesLineItemGridSpec(CurrentPerson, grantAllocationAward);
            var personnelAndBenefitsLineItemGridSpec = new PersonnelAndBenefitsLineItemGridSpec(CurrentPerson, grantAllocationAward);
            var travelLineItemGridSpec             = new TravelLineItemGridSpec(CurrentPerson, grantAllocationAward);
            var landownerCostShareLineItemGridSpec = new LandownerCostShareLineItemGridSpec(CurrentPerson, grantAllocationAward);
            var contractorInvoiceItemGridSpec      = new ContractorInvoiceItemGridSpec(CurrentPerson, grantAllocationAward);

            var viewData = new Views.GrantAllocationAward.DetailViewData(CurrentPerson,
                                                                         grantAllocationAward,
                                                                         backButtonUrl,
                                                                         backButtonText,
                                                                         suppliesLineItemGridSpec,
                                                                         personnelAndBenefitsLineItemGridSpec,
                                                                         travelLineItemGridSpec,
                                                                         landownerCostShareLineItemGridSpec,
                                                                         contractorInvoiceItemGridSpec);

            return(RazorView <Views.GrantAllocationAward.Detail, Views.GrantAllocationAward.DetailViewData>(viewData));
        }
        public PartialViewResult EditContractorInvoice(GrantAllocationAwardPrimaryKey grantAllocationAwardPrimaryKey)
        {
            var grantAllocationAward = grantAllocationAwardPrimaryKey.EntityObject;
            var viewModel            = new EditContractorInvoiceViewModel(grantAllocationAward);

            return(ContractorInvoiceViewEdit(viewModel));
        }
        public PartialViewResult NewContractorInvoiceItemFromGrantAllocationAward(GrantAllocationAwardPrimaryKey grantAllocationAwardPrimaryKey)
        {
            var grantAllocationAward = grantAllocationAwardPrimaryKey.EntityObject;
            var viewModel            = new EditGrantAllocationAwardContractorInvoiceItemViewModel()
            {
                GrantAllocationAwardID = grantAllocationAward.GrantAllocationAwardID
            };

            return(GrantAllocationAwardContractorInvoiceItemViewEdit(viewModel));
        }
        public ActionResult EditContractorInvoice(GrantAllocationAwardPrimaryKey grantAllocationAwardPrimaryKey, EditContractorInvoiceViewModel viewModel)
        {
            var grantAllocationAward = grantAllocationAwardPrimaryKey.EntityObject;

            if (!ModelState.IsValid)
            {
                return(ContractorInvoiceViewEdit(viewModel));
            }
            viewModel.UpdateModel(grantAllocationAward);
            return(new ModalDialogFormJsonResult());
        }
        public ActionResult NewTravelLineItemFromGrantAllocationAward(GrantAllocationAwardPrimaryKey grantAllocationAwardPrimaryKey, EditGrantAllocationAwardTravelLineItemViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(GrantAllocationAwardTravelLineItemViewEdit(viewModel));
            }

            var grantAllocationAward = HttpRequestStorage.DatabaseEntities.GrantAllocationAwards.Single(ga => ga.GrantAllocationAwardID == viewModel.GrantAllocationAwardID);
            var travelLineItem       = GrantAllocationAwardTravelLineItem.CreateNewBlank(grantAllocationAward, GrantAllocationAwardTravelLineItemType.Transportation);

            viewModel.UpdateModel(travelLineItem);
            return(new ModalDialogFormJsonResult());
        }
        public ActionResult NewContractorInvoiceItemFromGrantAllocationAward(GrantAllocationAwardPrimaryKey grantAllocationAwardPrimaryKey, EditGrantAllocationAwardContractorInvoiceItemViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(GrantAllocationAwardContractorInvoiceItemViewEdit(viewModel));
            }

            var grantAllocationAward  = HttpRequestStorage.DatabaseEntities.GrantAllocationAwards.Single(ga => ga.GrantAllocationAwardID == viewModel.GrantAllocationAwardID);
            var contractorInvoiceType = GrantAllocationAwardContractorInvoiceType.All.Single(x => x.GrantAllocationAwardContractorInvoiceTypeID == viewModel.TypeID);
            var contractorInvoice     = GrantAllocationAwardContractorInvoice.CreateNewBlank(grantAllocationAward, contractorInvoiceType);

            viewModel.UpdateModel(contractorInvoice, CurrentPerson);
            return(new ModalDialogFormJsonResult());
        }
        public ActionResult DeleteGrantAllocationAward(GrantAllocationAwardPrimaryKey grantAllocationAwardPrimaryKey, ConfirmDialogFormViewModel viewModel)
        {
            var grantAllocationAward = grantAllocationAwardPrimaryKey.EntityObject;

            if (!ModelState.IsValid)
            {
                return(ViewDeleteGrantAllocationAward(grantAllocationAward, viewModel));
            }

            var message = $"{FieldDefinition.GrantAllocationAward.GetFieldDefinitionLabel()} \"{grantAllocationAward.GrantAllocationAwardName}\" successfully deleted.";

            grantAllocationAward.DeleteFull(HttpRequestStorage.DatabaseEntities);
            SetMessageForDisplay(message);
            return(new ModalDialogFormJsonResult());
        }
        public ActionResult NewLandownerCostShareLineItemFromGrantAllocationAward(GrantAllocationAwardPrimaryKey grantAllocationAwardPrimaryKey, EditGrantAllocationAwardLandownerCostShareLineItemViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(GrantAllocationAwardLandownerCostShareLineItemViewEdit(viewModel));
            }

            var grantAllocationAward = HttpRequestStorage.DatabaseEntities.GrantAllocationAwards.Single(ga => ga.GrantAllocationAwardID == viewModel.GrantAllocationAwardID);
            var project = HttpRequestStorage.DatabaseEntities.Projects.Single(x => x.ProjectID == viewModel.ProjectID);
            var landownerCostShareLineItemStatus = LandownerCostShareLineItemStatus.All.Single(x => x.LandownerCostShareLineItemStatusID == viewModel.StatusID);
            var landownerCostShareLineItem       = GrantAllocationAwardLandownerCostShareLineItem.CreateNewBlank(project, landownerCostShareLineItemStatus);

            landownerCostShareLineItem.GrantAllocationAwardID = grantAllocationAward.GrantAllocationAwardID;
            viewModel.UpdateModel(landownerCostShareLineItem);
            return(new ModalDialogFormJsonResult());
        }
        public GridJsonNetJObjectResult <GrantAllocationAwardContractorInvoice> ContractorInvoiceItemGridJsonData(GrantAllocationAwardPrimaryKey grantAllocationAwardPrimaryKey)
        {
            var grantAllocationAward     = grantAllocationAwardPrimaryKey.EntityObject;
            var contractorInvoices       = grantAllocationAward.GrantAllocationAwardContractorInvoices;
            var gridSpec                 = new ContractorInvoiceItemGridSpec(CurrentPerson, grantAllocationAward);
            var gridJsonNetJObjectResult = new GridJsonNetJObjectResult <GrantAllocationAwardContractorInvoice>(contractorInvoices.ToList(), gridSpec);

            return(gridJsonNetJObjectResult);
        }
        public PartialViewResult NewLandownerCostShareLineItemFromGrantAllocationAward(GrantAllocationAwardPrimaryKey grantAllocationAwardPrimaryKey)
        {
            var grantAllocationAward = grantAllocationAwardPrimaryKey.EntityObject;
            var viewModel            = new EditGrantAllocationAwardLandownerCostShareLineItemViewModel()
            {
                GrantAllocationAwardID = grantAllocationAward.GrantAllocationAwardID
            };

            return(GrantAllocationAwardLandownerCostShareLineItemViewEdit(viewModel));
        }
        public GridJsonNetJObjectResult <GrantAllocationAwardLandownerCostShareLineItem> LandownerCostShareLineItemGridJsonData(GrantAllocationAwardPrimaryKey grantAllocationAwardPrimaryKey)
        {
            var grantAllocationAward        = grantAllocationAwardPrimaryKey.EntityObject;
            var landownerCostShareLineItems = grantAllocationAward.GrantAllocationAwardLandownerCostShareLineItems;
            var gridSpec = new LandownerCostShareLineItemGridSpec(CurrentPerson, grantAllocationAward);
            var gridJsonNetJObjectResult = new GridJsonNetJObjectResult <GrantAllocationAwardLandownerCostShareLineItem>(landownerCostShareLineItems.ToList(), gridSpec);

            return(gridJsonNetJObjectResult);
        }
        public GridJsonNetJObjectResult <GrantAllocationAwardTravelLineItem> TravelLineItemGridJsonData(GrantAllocationAwardPrimaryKey grantAllocationAwardPrimaryKey)
        {
            var grantAllocationAward     = grantAllocationAwardPrimaryKey.EntityObject;
            var travelLineItems          = grantAllocationAward.GrantAllocationAwardTravelLineItems;
            var gridSpec                 = new TravelLineItemGridSpec(CurrentPerson, grantAllocationAward);
            var gridJsonNetJObjectResult = new GridJsonNetJObjectResult <GrantAllocationAwardTravelLineItem>(travelLineItems.ToList(), gridSpec);

            return(gridJsonNetJObjectResult);
        }
        public PartialViewResult DeleteGrantAllocationAward(GrantAllocationAwardPrimaryKey grantAllocationAwardPrimaryKey)
        {
            var viewModel = new ConfirmDialogFormViewModel(grantAllocationAwardPrimaryKey.PrimaryKeyValue);

            return(ViewDeleteGrantAllocationAward(grantAllocationAwardPrimaryKey.EntityObject, viewModel));
        }
        public PartialViewResult NewPersonnelAndBenefitsLineItemFromGrantAllocationAward(GrantAllocationAwardPrimaryKey grantAllocationAwardPrimaryKey)
        {
            var grantAllocationAward = grantAllocationAwardPrimaryKey.EntityObject;
            var viewModel            = new EditGrantAllocationAwardPersonnelAndBenefitsLineItemViewModel()
            {
                GrantAllocationAwardID = grantAllocationAward.GrantAllocationAwardID
            };

            return(GrantAllocationAwardPersonnelAndBenefitsLineItemViewEdit(viewModel));
        }
        public GridJsonNetJObjectResult <GrantAllocationAwardPersonnelAndBenefitsLineItem> PersonnelAndBenefitsLineItemGridJsonData(GrantAllocationAwardPrimaryKey grantAllocationAwardPrimaryKey)
        {
            var grantAllocationAward          = grantAllocationAwardPrimaryKey.EntityObject;
            var personnelAndBenefitsLineItems = grantAllocationAward.GrantAllocationAwardPersonnelAndBenefitsLineItems;
            var gridSpec = new PersonnelAndBenefitsLineItemGridSpec(CurrentPerson, grantAllocationAward);
            var gridJsonNetJObjectResult = new GridJsonNetJObjectResult <GrantAllocationAwardPersonnelAndBenefitsLineItem>(personnelAndBenefitsLineItems.ToList(), gridSpec);

            return(gridJsonNetJObjectResult);
        }