Пример #1
0
        public PartialViewResult EditAgreementGrantAllocations(AgreementPrimaryKey agreementPrimaryKey)
        {
            var agreement = agreementPrimaryKey.EntityObject;
            var viewModel = new EditAgreementGrantAllocationsViewModel(agreement);

            return(ViewEditAgreementGrantAllocations(viewModel));
        }
Пример #2
0
        public PartialViewResult EditAgreementGrantAllocationRelationships(AgreementPrimaryKey agreementPrimaryKey)
        {
            var agreementId = agreementPrimaryKey.EntityObject.AgreementID;
            var agreement   = HttpRequestStorage.DatabaseEntities.Agreements.FirstOrDefault(ag => ag.AgreementID == agreementId);

            Check.EnsureNotNull(agreement);

            var viewModel = new EditAgreementGrantAllocationsViewModel(agreement);

            return(ViewEditAgreementGrantAllocations(viewModel));
        }
Пример #3
0
        public ActionResult EditAgreementGrantAllocationRelationships(AgreementPrimaryKey agreementPrimaryKey, EditAgreementGrantAllocationsViewModel viewModel)
        {
            // Find relevant agreement
            var agreement = agreementPrimaryKey.EntityObject;

            Check.EnsureNotNull(agreement);

            if (!ModelState.IsValid)
            {
                return(ViewEditAgreementGrantAllocations(viewModel));
            }
            var grantAllocationsCurrentlyOnAgreement = agreement.AgreementGrantAllocations.Select(x => x.GrantAllocationID).ToList();
            var grantAllocationsFromPost             = viewModel.GrantAllocationJsons.Select(x => x.GrantAllocationID).ToList();
            var countAdded   = grantAllocationsFromPost.Except(grantAllocationsCurrentlyOnAgreement).Count();
            var countDeleted = grantAllocationsCurrentlyOnAgreement.Except(grantAllocationsFromPost).Count();

            viewModel.UpdateModel(agreement);

            HttpRequestStorage.DatabaseEntities.SaveChanges();
            var finalMessage = MakeGrantAllocationSuccessMessage(countAdded, countDeleted, agreement);

            SetMessageForDisplay(finalMessage);
            return(new ModalDialogFormJsonResult());
        }
Пример #4
0
        private PartialViewResult ViewEditAgreementGrantAllocations(EditAgreementGrantAllocationsViewModel viewModel)
        {
            var viewData = new EditAgreementGrantAllocationsViewData();

            return(RazorPartialView <EditAgreementGrantAllocations, EditAgreementGrantAllocationsViewData, EditAgreementGrantAllocationsViewModel>(viewData, viewModel));
        }