Beispiel #1
0
        public async Task <IActionResult> PutMinneapolisItem([FromRoute] int id, [FromBody] MinneapolisItem minneapolisItem)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(NoContent());
        }
Beispiel #2
0
        public async Task <IActionResult> PostMinneapolisItem([FromBody] MinneapolisItem minneapolisItem)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.MinneapolisItems.Add(minneapolisItem);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetMinneapolisItem", new { id = minneapolisItem.Id }, minneapolisItem));
        }