예제 #1
0
        public ActionResult EditGrantAllocationBudgetLineItem(GrantAllocationBudgetLineItemPrimaryKey grantAllocationBudgetLineItemPrimaryKey, EditGrantAllocationBudgetLineItemViewModel viewModel)
        {
            var grantAllocationBudgetLineItem = grantAllocationBudgetLineItemPrimaryKey.EntityObject;

            if (!ModelState.IsValid)
            {
                return(ViewEditGrantAllocationBudgetLineItem(viewModel));
            }
            viewModel.UpdateModel(grantAllocationBudgetLineItem);
            return(new ModalDialogFormJsonResult());
        }
예제 #2
0
        public ActionResult NewGrantAllocationBudgetLineItem(GrantAllocationPrimaryKey grantAllocationPrimaryKey, EditGrantAllocationBudgetLineItemViewModel viewModel)
        {
            var grantAllocation = grantAllocationPrimaryKey.EntityObject;

            if (!ModelState.IsValid)
            {
                return(ViewEditGrantAllocationBudgetLineItem(viewModel));
            }

            var grantAllocationBudgetLineItem = new GrantAllocationBudgetLineItem(viewModel.GrantAllocationID, viewModel.CostTypeID, viewModel.GrantAllocationBudgetLineItemAmount);

            viewModel.UpdateModel(grantAllocationBudgetLineItem);
            HttpRequestStorage.DatabaseEntities.GrantAllocationBudgetLineItems.Add(grantAllocationBudgetLineItem);
            HttpRequestStorage.DatabaseEntities.SaveChanges();
            SetMessageForDisplay($"{FieldDefinition.GrantAllocationBudgetLineItem.GetFieldDefinitionLabel()} successfully added to this {FieldDefinition.GrantAllocation.GetFieldDefinitionLabel()}.");

            return(new ModalDialogFormJsonResult());
        }