public async Task <ActionResult <DetalheVendaClienteBenefic> > Put( int id, [FromServices] DataContext context, [FromBody] DetalheVendaClienteBenefic model) { if (id != model.Id) { return(NotFound(new { message = "Não encontrado" })); } if (!ModelState.IsValid) { return(BadRequest(ModelState)); } try { context.Entry <DetalheVendaClienteBenefic>(model).State = EntityState.Modified; await context.SaveChangesAsync(); return(Ok(model)); } catch (DbUpdateConcurrencyException) { return(BadRequest(new { message = "Registro ja fpoi atualizado" })); } catch { return(BadRequest(new { message = "Não foi possivel atualizar o cadastro" })); } }
public async Task <ActionResult <DetalheVendaClienteBenefic> > Post( [FromServices] DataContext context, [FromBody] DetalheVendaClienteBenefic model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } try { context.DetalheVendaClienteBenefic.Add(model); await context.SaveChangesAsync(); return(Ok(model)); } catch { return(BadRequest(new { message = "Não foi possivel concluir o cadastro" })); } }