Example #1
0
        public async Task <IActionResult> PostTCocinero([FromBody] TCocinero tCocinero)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            tCocinero.BActivo   = (byte)Estados.EstadoEnum.Activo;
            tCocinero.FCreacion = DateTime.Now;
            _context.TCocinero.Add(tCocinero);
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (TCocineroExists(tCocinero.IdCocinero))
                {
                    return(new StatusCodeResult(StatusCodes.Status409Conflict));
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtAction("GetTCocinero", new { id = tCocinero.IdCocinero }, tCocinero));
        }
Example #2
0
        public async Task <IActionResult> PutTCocinero([FromRoute] int id, [FromBody] TCocinero tCocinero)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != tCocinero.IdCocinero)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }