Example #1
0
        public async Task <IActionResult> PutSottocategoria([FromRoute] int id, [FromBody] Sottocategoria sottocategoria)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != sottocategoria.Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Example #2
0
        public async Task <IActionResult> PostSottocategoria([FromBody] Sottocategoria sottocategoria)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.Sottocategoria.Add(sottocategoria);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetSottocategoria", new { id = sottocategoria.Id }, sottocategoria));
        }