Exemplo n.º 1
0
        public async Task <IActionResult> PutAreaAtendimento([FromRoute] int id, [FromBody] AreaAtendimento areaAtendimento)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != areaAtendimento.CdAreaatendimento)
            {
                return(BadRequest());
            }

            _context.Entry(areaAtendimento).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!AreaAtendimentoExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(Ok(areaAtendimento));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> PostAreaAtendimento([FromBody] AreaAtendimento areaAtendimento)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.AreaAtendimento.Add(areaAtendimento);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetAreaAtendimento", new { id = areaAtendimento.CdAreaatendimento }, areaAtendimento));
        }