//[Authorize(Roles = "usuario")] public async Task <ActionResult <HistoricPassword> > Put( int id, [FromServices] DataContext context, [FromBody] HistoricPassword model, [FromServices] IHistoricPasswordService historicPasswordService) { var historicPassword = await historicPasswordService.GetHistoricPassword(context, id); if (historicPassword == null) { return(NotFound(new { historicPassword = "******" })); } if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var putHistoricPassword = await historicPasswordService.PutHistoricPassword(context, model); if (putHistoricPassword != null) { return(Ok(model)); } return(BadRequest(new { historicPassword = "******" })); }
public async Task <dynamic> DeleteHistoricPassword( DataContext context, HistoricPassword model) { try { context.Passwords.Remove(model); await context.SaveChangesAsync(); return(new { okMessage = "HistoricPassword deletado com sucesso!" }); } catch { return(new { badMessage = "Não foi possível excluir o HistoricPassword." }); } }
public async Task <dynamic> PutHistoricPassword( DataContext context, HistoricPassword model) { try { context.Entry <HistoricPassword>(model).State = EntityState.Modified; await context.SaveChangesAsync(); return(model); } catch { return(null); } }
public async Task <HistoricPassword> PostHistoricPassword( DataContext context, HistoricPassword model ) { try { context.Passwords.Add(model); await context.SaveChangesAsync(); return(model); } catch { return(null); } }
//[AllowAnonymous] public async Task <ActionResult <HistoricPassword> > Post( [FromBody] HistoricPassword model, [FromServices] DataContext context, [FromServices] IHistoricPasswordService historicPasswordService ) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var postHistoricPassword = await historicPasswordService.PostHistoricPassword(context, model); if (postHistoricPassword == null) { return(BadRequest(new { historicPassword = "******" })); } return(Ok(model)); }