public async Task <Models.TbLivroAutor> AlterarLivroAutor(int id, Models.TbLivroAutor novaTabela) { Models.TbLivroAutor tabela = await ConsultarPorIdLivroAutor(id); tabela.IdAutor = novaTabela.IdAutor; tabela.IdLivro = novaTabela.IdLivro; return(tabela); }
public async Task <Models.TbLivroAutor> CadastrarLivroAutor(Models.TbLivroAutor tabela) { await context.AddAsync(tabela); await context.SaveChangesAsync(); return(tabela); }
public Models.TbLivroAutor ConversorTabela(Models.Request.LivroAutorRequest request) { Models.TbLivroAutor tabela = new Models.TbLivroAutor(); tabela.IdLivro = request.livro; tabela.IdAutor = request.autor; return(tabela); }
public async Task <Models.TbLivroAutor> DeletarLivroAutor(int id) { Models.TbLivroAutor tabela = await ConsultarPorIdLivroAutor(id); context.TbLivroAutor.Remove(tabela); await context.SaveChangesAsync(); return(tabela); }
public Models.Response.LivroAutorResponse ConversorResponse(Models.TbLivroAutor tabela) { Models.Response.LivroAutorResponse response = new Models.Response.LivroAutorResponse(); response.id = tabela.IdLivroAutor; response.livro = tabela.IdLivro; response.autor = tabela.IdAutor; return(response); }
public async Task <ActionResult <Models.Response.LivroAutorResponse> > AlterarLivroAutor(int idlivroautor, Models.Request.LivroAutorRequest request) { try { Models.TbLivroAutor tabela = conversor.ConversorTabela(request); tabela = await business.ValidarAlterarLivroAutor(idlivroautor, tabela); return(conversor.ConversorResponse(tabela)); } catch (System.Exception ex) { return(new NotFoundObjectResult(new Models.Response.ErroResponse(404, ex.Message))); } }
public async Task <ActionResult <Models.Response.LivroAutorResponse> > CadastrarLivroAutor(Models.Request.LivroAutorRequest request) { try { Models.TbLivroAutor tabela = conversor.ConversorTabela(request); tabela = await business.ValidarCadastroLivroAutor(tabela); return(conversor.ConversorResponse(tabela)); } catch (System.Exception ex) { return(BadRequest(new Models.Response.ErroResponse(400, ex.Message))); } }
public async Task <Models.TbLivroAutor> ValidarCadastroLivroAutor(Models.TbLivroAutor tabela) { ValidarId(tabela.IdLivro); ValidarId(tabela.IdAutor); return(await database.CadastrarLivroAutor(tabela)); }
public async Task <Models.TbLivroAutor> ValidarAlterarLivroAutor(int id, Models.TbLivroAutor tabela) { ValidarId(tabela.IdLivro); ValidarId(tabela.IdAutor); return(await database.AlterarLivroAutor(id, tabela)); }