Beispiel #1
0
        public async Task <ActionResult <Models.Response.VendaResponse> > CadastrarVenda(Models.Request.VendaRequest request)
        {
            try
            {
                Models.TbVenda tabela = conversor.ConversorTabela(request);
                tabela = await business.InserirBusiness(tabela);

                return(conversor.ConversorResponse(tabela));
            }
            catch (System.Exception ex)
            {
                return(BadRequest(new Models.Response.ErroResponse(400, ex.Message)));
            }
        }
        public async Task <ActionResult> RealizarVenda(Models.Request.RealizarVendaRequest.RealizarVendaPersonalizado request)
        {
            try
            {
                Models.TbVenda tabela = conversor.ParaTabelaVenda(request);
                await estoquebusiness.RetirarQuantidadeVendidaBusiness(tabela.TbVendaLivro.ToList());

                carrinhobusiness.ValidarRetirarDoCarrinho(request.IdCliente);
                tabela = await business.InserirBusiness(tabela);

                return(Ok());
            }
            catch (System.Exception ex)
            {
                return(BadRequest(new Models.Response.ErroResponse(400, ex.Message)));
            }
        }