public async Task <Models.TbLivroGenero> ValidarAlterarLivroGenero(int id, Models.TbLivroGenero tabela) { ValidarId(id); ValidarId(tabela.IdGenero); ValidarId(tabela.IdLivro); return(await database.AlterarLivroGenero(id, tabela)); }
public async Task <Models.TbLivroGenero> CadastrarLivroGenero(Models.TbLivroGenero tabela) { await context.TbLivroGenero.AddAsync(tabela); await context.SaveChangesAsync(); return(tabela); }
public Models.TbLivroGenero ConversorTabela(Models.Request.LivroGeneroRequest request) { Models.TbLivroGenero tabela = new Models.TbLivroGenero(); tabela.IdLivro = request.livro; tabela.IdGenero = request.genero; return(tabela); }
public async Task <Models.TbLivroGenero> DeletarLivroGenero(int id) { Models.TbLivroGenero tabela = await ConsultarPorIdLivroGenero(id); context.TbLivroGenero.Remove(tabela); await context.SaveChangesAsync(); return(tabela); }
public Models.Response.LivroGeneroResponse ConversorResponse(Models.TbLivroGenero tabela) { Models.Response.LivroGeneroResponse response = new Models.Response.LivroGeneroResponse(); response.id = tabela.IdLivroGenero; response.livro = tabela.IdLivro; response.genero = tabela.IdGenero; return(response); }
public async Task <Models.TbLivroGenero> AlterarLivroGenero(int id, Models.TbLivroGenero novaTabela) { Models.TbLivroGenero tabela = await ConsultarPorIdLivroGenero(id); tabela.IdGenero = novaTabela.IdGenero; tabela.IdLivro = novaTabela.IdLivro; await context.SaveChangesAsync(); return(tabela); }
public async Task <ActionResult <Models.Response.LivroGeneroResponse> > AlterarLivroGenero(int idlivrogenero, Models.Request.LivroGeneroRequest request) { try { Models.TbLivroGenero tabela = conversor.ConversorTabela(request); tabela = await business.ValidarAlterarLivroGenero(idlivrogenero, 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.LivroGeneroResponse> > CadastrarLivroGenero(Models.Request.LivroGeneroRequest request) { try { Models.TbLivroGenero tabela = conversor.ConversorTabela(request); tabela = await business.ValidarCadastrarLivroGenero(tabela); return(conversor.ConversorResponse(tabela)); } catch (System.Exception ex) { return(BadRequest(new Models.Response.ErroResponse(404, ex.Message))); } }
public async Task <Models.TbLivroGenero> ValidarCadastrarLivroGenero(Models.TbLivroGenero tabela) { ValidarId(tabela.IdLivro); ValidarId(tabela.IdGenero); return(await database.CadastrarLivroGenero(tabela)); }