Ejemplo n.º 1
0
 public IActionResult AddContractorInvoiceItem(int invoiceId, NewContractorInvoiceItem vm)
 {
     if (ModelState.IsValid)
     {
         _contractorService.AddContractorInvoiceItem(vm);
         return(RedirectToAction(nameof(Index), new { id = vm.InvoiceId }));
     }
     return(View(vm));
 }
Ejemplo n.º 2
0
        public void AddContractorInvoiceItem(NewContractorInvoiceItem vm)
        {
            var contractor = _context.Contractors
                             .Include(c => c.ContractorInvoices)
                             .ThenInclude(i => i.ContractorInvoiceItems)
                             .SingleOrDefault(x => x.Id == vm.InvoiceId);

            //var invoice = contractor.ContractorInvoices
            //    .Where(i => i.Id == vm.InvoiceId)
            //    .SingleOrDefault();

            var newItem = new ContractorInvoiceItem
            {
                //ContractorInvoiceId = contractor.ContractorInvoices.Id;
                Item     = vm.Item,
                Amount   = vm.Amount,
                GST      = vm.GST,
                Onbill   = vm.Onbill,
                ItemNote = vm.ItemNote
            };

            //invoice.ContractorInvoiceItems.Add(newItem);
            _context.SaveChanges();
        }