public async Task <IHttpActionResult> PuttNutrientType(int id, tNutrientType NutrientType) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != NutrientType.ID) { return(BadRequest()); } db.Entry(NutrientType).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!tNutrientTypeExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IHttpActionResult> GettNutrientType(int id) { tNutrientType tNutrientType = await db.tNutrientTypes.FindAsync(id); if (tNutrientType == null) { return(NotFound()); } return(Ok(tNutrientType)); }
public async Task <IHttpActionResult> PosttNutrientType(tNutrientType NutrientType) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.tNutrientTypes.Add(NutrientType); await db.SaveChangesAsync(); return(CreatedAtRoute("DefaultApi", new { id = NutrientType.ID }, NutrientType)); }
public async Task <IHttpActionResult> DeletetNutrientType(int id) { tNutrientType tNutrientType = await db.tNutrientTypes.FindAsync(id); if (tNutrientType == null) { return(NotFound()); } db.tNutrientTypes.Remove(tNutrientType); await db.SaveChangesAsync(); return(Ok(tNutrientType)); }