public async Task <IHttpActionResult> PutBrowarnia(int id, Browarnia browarnia) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != browarnia.Id) { return(BadRequest()); } db.Entry(browarnia).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BrowarniaExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IHttpActionResult> PostBrowarnia(Browarnia browarnia) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Browarnias.Add(browarnia); await db.SaveChangesAsync(); return(CreatedAtRoute("DefaultApi", new { id = browarnia.Id }, browarnia)); }
public async Task <IHttpActionResult> DeleteBrowarnia(int id) { Browarnia browarnia = await db.Browarnias.FindAsync(id); if (browarnia == null) { return(NotFound()); } db.Browarnias.Remove(browarnia); await db.SaveChangesAsync(); return(Ok(browarnia)); }