Exemplo n.º 1
0
        // PUT api/Meal/2014-04-19
        public IHttpActionResult PutMeal(string date, Meal meal)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (date != meal.MealDate)
            {
                return(BadRequest());
            }

            db.Entry(meal).State = EntityState.Modified;
            meal.Dishes          = findOrAddDishes(meal.Dishes);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!MealExists(date))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemplo n.º 2
0
        // PUT api/Dish/5
        public IHttpActionResult PutDish(int id, Dish dish)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != dish.DishId)
            {
                return(BadRequest());
            }

            db.Entry(dish).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!DishExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemplo n.º 3
0
        public bool AddSignup(AddSignupRequest request)
        {
            if (request != null)
            {
                SignUp data = new SignUp();
                data.Username = request.Username;
                data.Password = request.Password;

                _db.Signup.Add(data);
                _db.SaveChanges();

                return(true);
            }
            if (request == null)
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }
            return(false);
        }