public async Task <IHttpActionResult> PutAdmixtures(int id, Admixtures admixtures) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != admixtures.IngredientsId) { return(BadRequest()); } db.Entry(admixtures).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AdmixturesExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IHttpActionResult> GetAdmixtures(int id) { Admixtures admixtures = await db.Admixtures.FindAsync(id); if (admixtures == null) { return(NotFound()); } return(Ok(admixtures)); }
public async Task <IHttpActionResult> PostAdmixtures(Admixtures admixtures) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Admixtures.Add(admixtures); await db.SaveChangesAsync(); return(CreatedAtRoute("DefaultApi", new { id = admixtures.IngredientsId }, admixtures)); }
public async Task <IHttpActionResult> DeleteAdmixtures(int id) { Admixtures admixtures = await db.Admixtures.FindAsync(id); if (admixtures == null) { return(NotFound()); } db.Admixtures.Remove(admixtures); await db.SaveChangesAsync(); return(Ok(admixtures)); }