예제 #1
0
        public PartialViewResult NewInvoiceLineItem(InvoicePrimaryKey invoicePrimaryKey)
        {
            var invoiceID = invoicePrimaryKey.EntityObject.InvoiceID;
            var viewModel = new EditInvoiceLineItemViewModel(invoiceID);

            return(ViewEditInvoiceLineItem(viewModel));
        }
예제 #2
0
        public PartialViewResult EditInvoiceLineItem(InvoiceLineItemPrimaryKey invoiceLineItemPrimaryKey)
        {
            var invoiceLineItem = invoiceLineItemPrimaryKey.EntityObject;
            var viewModel       = new EditInvoiceLineItemViewModel(invoiceLineItem);

            return(ViewEditInvoiceLineItem(viewModel));
        }
예제 #3
0
        private PartialViewResult ViewEditInvoiceLineItem(EditInvoiceLineItemViewModel viewModel)
        {
            var costTypes        = CostType.All.Where(x => x.IsValidInvoiceLineItemCostType).ToList();
            var grantAllocations = HttpRequestStorage.DatabaseEntities.GrantAllocations.ToList();
            var viewData         = new EditInvoiceLineItemViewData(grantAllocations, costTypes);

            return(RazorPartialView <EditInvoiceLineItem, EditInvoiceLineItemViewData, EditInvoiceLineItemViewModel>(viewData, viewModel));
        }
예제 #4
0
        public ActionResult NewInvoiceLineItem(InvoicePrimaryKey invoicePrimaryKey, EditInvoiceLineItemViewModel viewModel)
        {
            var invoiceID = invoicePrimaryKey.EntityObject.InvoiceID;

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

            var invoiceLineItem = new InvoiceLineItem(invoiceID, viewModel.GrantAllocationID, viewModel.CostTypeID,
                                                      viewModel.InvoiceLineItemAmount);

            viewModel.UpdateModel(invoiceLineItem);
            HttpRequestStorage.DatabaseEntities.InvoiceLineItems.Add(invoiceLineItem);
            HttpRequestStorage.DatabaseEntities.SaveChanges();
            SetMessageForDisplay($"Invoice Line Item successfully added to this {FieldDefinition.Invoice.GetFieldDefinitionLabel()}.");

            return(new ModalDialogFormJsonResult());
        }
예제 #5
0
        public ActionResult EditInvoiceLineItem(InvoiceLineItemPrimaryKey invoiceLineItemPrimaryKey, EditInvoiceLineItemViewModel viewModel)
        {
            var invoiceLineItem = invoiceLineItemPrimaryKey.EntityObject;

            if (!ModelState.IsValid)
            {
                return(ViewEditInvoiceLineItem(viewModel));
            }
            viewModel.UpdateModel(invoiceLineItem);
            return(new ModalDialogFormJsonResult());
        }