Ejemplo n.º 1
0
        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));
        }
Ejemplo n.º 2
0
        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));
        }
Ejemplo n.º 3
0
        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));
        }
Ejemplo n.º 4
0
        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));
        }