Esempio n. 1
0
        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());
        }
Esempio n. 2
0
        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());
        }
Esempio n. 3
0
        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));
        }