public async Task <ActionResult <DishItem> > PostDishItem(DishItem item) { _context.DishItems.Add(item); await _context.SaveChangesAsync(); return(CreatedAtAction(nameof(GetDishItem), new { id = item.Id }, item)); }
public async Task <IActionResult> PutRestItem(long id, RestItem restItem) { if (id != restItem.Id) { return(BadRequest()); } _context.Entry(restItem).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RestItemExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
// PUT: odata/Pessoas(5) public async Task <IHttpActionResult> Put([FromODataUri] int key, Delta <Pessoa> patch) { Validate(patch.GetEntity()); if (!ModelState.IsValid) { return(BadRequest(ModelState)); } Pessoa pessoa = await db.Pessoas.FindAsync(key); if (pessoa == null) { return(NotFound()); } patch.Put(pessoa); try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PessoaExists(key)) { return(NotFound()); } else { throw; } } return(Updated(pessoa)); }