Exemple #1
0
        public IActionResult AddInvoice([FromBody] InvoiceDTO inv)
        {
            var id = _context.GetClientId(inv.client.Name, inv.client.Nip);

            if (id != 0)
            {
                var invoice = _mapper.Map <Invoice>(inv);
                invoice.ClientId      = id;
                invoice.PaymentTypeId = inv.PaymentType.PaymentTypeId;
                invoice.Client        = null;
                invoice.PaymentType   = null;
                var invoiceId = _context.AddInvoice(invoice);
                return(Ok());
            }
            else
            {
                var invoice = _mapper.Map <Invoice>(inv);
                invoice.PaymentType   = null;
                invoice.PaymentTypeId = inv.PaymentType.PaymentTypeId;
                var invoiceId = _context.AddInvoice(invoice);
                return(Ok());
            }
        }