public async Task <Models.TbDevolucao> CadastrarDevolucao(Models.TbDevolucao tabela) { await context.TbDevolucao.AddAsync(tabela); await context.SaveChangesAsync(); return(tabela); }
public async Task <Models.TbDevolucao> DeletarDevolucao(int id) { Models.TbDevolucao tabela = await ConsultarDevolucaoPorId(id); context.TbDevolucao.Remove(tabela); await context.SaveChangesAsync(); return(tabela); }
public void ValidarDevolucao(Models.TbDevolucao tabela) { if (tabela == null) { throw new ArgumentException("Essa tabela esta vazia"); } ValidarTexto(tabela.DsComprovante, " Comprovante"); ValidarTexto(tabela.DsCodigoRastreio, "Codigo de Rastreio"); ValidarTexto(tabela.DsMotivo, "Motivo"); ValidarData(tabela.DtDevolucao, "Data de Devolucao"); ValidarId(tabela.IdVendaLivro); }
public async Task <ActionResult <Models.Response.DevolucaoResponse> > AlterarDevolucao(int iddevolucao, Models.Request.DevolucaoRequest request) { try { Models.TbDevolucao tabela = conversor.ConversorTabela(request); tabela = await business.ValidarAlterarDevolucao(iddevolucao, tabela); return(conversor.ConversorResponse(tabela)); } catch (System.Exception ex) { return(new NotFoundObjectResult(new Models.Response.ErroResponse(404, ex.Message))); } }
public Models.TbDevolucao ConversorTabela(Models.Request.DevolucaoRequest request) { Models.TbDevolucao tabela = new Models.TbDevolucao(); tabela.IdVendaLivro = request.vendalivro; tabela.DsCodigoRastreio = "...."; tabela.DsMotivo = request.motivo; tabela.DtDevolucao = DateTime.Now; tabela.DtPrevisaoEntrega = request.previsao_entrega; tabela.BtDevolvido = 1; tabela.VlDevolvido = request.valor; return(tabela); }
public async Task <Models.TbDevolucao> AlterarDevolucao(int id, Models.TbDevolucao novaTabela) { Models.TbDevolucao tabela = await ConsultarDevolucaoPorId(id); tabela.IdVendaLivro = novaTabela.IdVendaLivro; tabela.VlDevolvido = novaTabela.VlDevolvido; tabela.BtDevolvido = novaTabela.BtDevolvido; tabela.DsCodigoRastreio = novaTabela.DsCodigoRastreio; tabela.DsComprovante = novaTabela.DsComprovante; tabela.DtDevolucao = novaTabela.DtDevolucao; tabela.DtPrevisaoEntrega = novaTabela.DtPrevisaoEntrega; await context.SaveChangesAsync(); return(tabela); }
public Models.Response.DevolucaoResponse ConversorResponse(Models.TbDevolucao tabela) { Models.Response.DevolucaoResponse response = new Models.Response.DevolucaoResponse(); response.id = tabela.IdDevolucao; response.vendalivro = tabela.IdVendaLivro; response.codigo_ratreio = tabela.DsCodigoRastreio; response.motivo = tabela.DsMotivo; response.data_devolucao = tabela.DtDevolucao; response.previsao_entrega = tabela.DtPrevisaoEntrega; response.devolvido = tabela.BtDevolvido; response.valor = tabela.VlDevolvido; return(response); }
public async Task <ActionResult <Models.Response.DevolucaoResponse> > CadastrarDevolucao([FromForm] Models.Request.DevolucaoRequest request) { try { Models.TbDevolucao tabela = conversor.ConversorTabela(request); tabela.DsComprovante = gerenciadorFoto.GerarNovoNome(request.comprovante.FileName); tabela = await business.ValidarCadastrarDevoucao(tabela); gerenciadorFoto.SalvarFile(tabela.DsComprovante, request.comprovante); await devolver.AlterarDevolvido(tabela.IdVendaLivro); return(conversor.ConversorResponse(tabela)); } catch (System.Exception ex) { return(BadRequest(new Models.Response.ErroResponse(400, ex.Message))); } }
public async Task <Models.TbDevolucao> ValidarCadastrarDevoucao(Models.TbDevolucao tabela) { ValidarDevolucao(tabela); return(await database.CadastrarDevolucao(tabela)); }
public async Task <Models.TbDevolucao> ValidarAlterarDevolucao(int id, Models.TbDevolucao tabela) { ValidarId(id); ValidarDevolucao(tabela); return(await database.AlterarDevolucao(id, tabela)); }