Ejemplo n.º 1
0
        public async Task <ActionResult <ProductInvoiceViewModel> > PostProductInvoice(
            ProductInvoiceInputModel productInvoiceModel)
        {
            ProductInvoice productInvoice = _mapper.Map <ProductInvoice>(productInvoiceModel);
            await _productInvoicesRepository.Insert(productInvoice);

            await _unitWork.SaveAsync();

            return(_mapper.Map <ProductInvoiceViewModel>(productInvoice));
        }
Ejemplo n.º 2
0
        public async Task Save_Valid_ProductInvoice()
        {
            try
            {
                ProductInvoice productInvoice = new ProductInvoice
                {
                    State    = InvoiceState.Generated,
                    ClientId = "12345678",
                };

                productInvoice.CalculateTotal();

                await _productInvoicesRepository.Insert(productInvoice);

                await _dbContext.SaveChangesAsync();

                Assert.Pass();
            }
            catch (DbUpdateException e)
            {
                Assert.Fail(e.Message);
            }
        }