Exemple #1
0
        public InvoicePersist Add(InvoicePersist invoiceInput)
        {
            Invoice invoiceModel = new Invoice
            {
                CustomerId = invoiceInput.CustomerId
                ,
                IssueDate      = invoiceInput.IssueDate
                , InvoiceLines = new List <InvoiceLine>()
            };

            invoiceModel.InvoiceLines.AddRange(invoiceInput
                                               .InvoiceLines
                                               .Select(x => new InvoiceLine
            {
                Invoice = invoiceModel
                ,
                Price = x.Price
                ,
                Qty = x.Qty
                ,
                ProductId = x.ProductId
            }));

            var entry = ctx.Invoices.Add(invoiceModel);

            invoiceInput.InvoiceId = entry.Entity.InvoiceId;
            invoiceInput.InvoiceLines.Clear();
            invoiceInput.InvoiceLines.AddRange(entry
                                               .Entity
                                               .InvoiceLines
                                               .Select(x => new InvoiceLinePersist
            {
                InvoiceId       = x.InvoiceId
                , InvoiceLineId = x.InvoiceLineId
                , Price         = x.Price
                , ProductId     = x.ProductId
                , Qty           = x.Qty
            }));

            return(invoiceInput);
        }
Exemple #2
0
 public InvoicePersist Add(InvoicePersist invoiceInput)
 {
     return(unitOfWork.InvoiceRepo.Add(invoiceInput));
 }