public IHttpActionResult Putmeal_plan(decimal id, meal_plan meal_plan) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != meal_plan.id_mealplan) { return(BadRequest()); } db.Entry(meal_plan).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!meal_planExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult Getmeal_plan(decimal id) { meal_plan meal_plan = db.meal_plan.Find(id); if (meal_plan == null) { return(NotFound()); } return(Ok(meal_plan)); }
public IHttpActionResult Postmeal_plan(meal_plan meal_plan) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.meal_plan.Add(meal_plan); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = meal_plan.id_mealplan }, meal_plan)); }
public IHttpActionResult Deletemeal_plan(decimal id) { meal_plan meal_plan = db.meal_plan.Find(id); if (meal_plan == null) { return(NotFound()); } db.meal_plan.Remove(meal_plan); db.SaveChanges(); return(Ok(meal_plan)); }