Exemplo n.º 1
0
        public async Task <ActionResult <Invoice> > PostInvoice(InvoicePostModel invoice)
        {
            Invoice NewInvoice = _mapper.Map <Invoice>(invoice);

            _context.Invoices.Add(NewInvoice);
            bool isSave = await _context.SaveChangesAsync() != 0;

            if (isSave)
            {
                await _cartServices.DeleteCartByUserIdAsync(NewInvoice.UserId);

                return(Ok(new { data = new { InvoiceId = NewInvoice.Id }, success = true }));
            }
            else
            {
                return(Ok(new { error_message = "Co loi xay ra" }));
            }
        }