public async Task <IActionResult> PutSolicitacao(int id, Solicitacao solicitacao) { if (id != solicitacao.Id) { return(BadRequest()); } _context.Entry(solicitacao).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SolicitacaoExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutUser(int id, User user) { if (id != user.Id) { return(BadRequest()); } _context.Entry(user).State = EntityState.Modified; try { await _context.SaveChangesAsync(Request); } catch (DbUpdateConcurrencyException) { if (!UserExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <ActionResult> Post(Ponto ponto) { var pontoExists = _context.Pontos.Any(e => e.UserId == ponto.UserId && e.Dia == ponto.Dia); if (pontoExists) { return(Forbid("Ponto já adicionado.")); } _context.Pontos.Add(ponto); await _context.SaveChangesAsync(Request); return(CreatedAtAction("Get", new { id = ponto.Id }, ponto)); }