//[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 = "******" })); }
//[Authorize(Roles ="admin")] public async Task <ActionResult <List <HistoricPassword> > > Get( [FromServices] DataContext contexto, [FromServices] IHistoricPasswordService historicPasswordService ) { var historicPasswords = await historicPasswordService.GetAllHistoricPassword(contexto); if (historicPasswords == null) { return(NotFound(new { historicPassword = "******" })); } return(Ok(historicPasswords)); }
//[Authorize(Roles = "usuario")] public async Task <ActionResult <HistoricPassword> > GetById( int id, [FromServices] DataContext context, [FromServices] IHistoricPasswordService historicPasswordService ) { var historicPassword = await historicPasswordService.GetHistoricPassword(context, id); if (historicPassword == null) { return(NotFound(new { historicPassword = "******" })); } return(Ok(historicPassword)); }
//[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)); }
//[Authorize(Roles = "admin")] public async Task <ActionResult <HistoricPassword> > Delete( int id, [FromServices] DataContext context, [FromServices] IHistoricPasswordService historicPasswordService ) { var historicPassword = await historicPasswordService.GetHistoricPassword(context, id); if (historicPassword == null) { return(NotFound(new { historicPassword = "******" })); } var deleteHistoricPassword = await historicPasswordService.DeleteHistoricPassword(context, historicPassword); if (deleteHistoricPassword.okHistoricPassword) { return(Ok(deleteHistoricPassword)); } return(BadRequest(deleteHistoricPassword)); }