public async Task <IHttpActionResult> PutRuokaKommentit(int id, RuokaKommentit ruokaKommentit) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != ruokaKommentit.ruoKommenttiId) { return(BadRequest()); } db.Entry(ruokaKommentit).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RuokaKommentitExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IHttpActionResult> GetRuokaKommentit(int id) { RuokaKommentit ruokaKommentit = await db.RuokaKommentit.FindAsync(id); if (ruokaKommentit == null) { return(NotFound()); } return(Ok(ruokaKommentit)); }
public async Task <IHttpActionResult> PostRuokaKommentit(RuokaKommentit ruokaKommentit) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.RuokaKommentit.Add(ruokaKommentit); await db.SaveChangesAsync(); return(CreatedAtRoute("DefaultApi", new { id = ruokaKommentit.ruoKommenttiId }, ruokaKommentit)); }
public async Task <IHttpActionResult> DeleteRuokaKommentit(int id) { RuokaKommentit ruokaKommentit = await db.RuokaKommentit.FindAsync(id); if (ruokaKommentit == null) { return(NotFound()); } db.RuokaKommentit.Remove(ruokaKommentit); await db.SaveChangesAsync(); return(Ok(ruokaKommentit)); }