public IHttpActionResult CreateOrder(int mealId, OrderBindingModel orderModel)
        {
            if (orderModel == null)
            {
                return this.BadRequest("Order data cannot be null.");
            }

            if (!this.ModelState.IsValid)
            {
                return this.BadRequest(this.ModelState);
            }

            var existingMeal = this.Data.Meals.All()
                .FirstOrDefault(r => r.Id == mealId);
            if (existingMeal == null)
            {
                return this.NotFound();
            }

            var loggedUserId = this.UserIdProvider.GetUserId();
            if (loggedUserId == null)
            {
                return this.Unauthorized();
            }

            var newOrder = new Order
            {
                Quantity = orderModel.Quantity,
                MealId = mealId,
                Meal = existingMeal,
                UserId = loggedUserId,
                CreatedOn = DateTime.Now,
                OrderStatus = OrderStatus.Pending
            };

            this.Data.Orders.Add(newOrder);
            this.Data.SaveChanges();

            return this.Ok(string.Format("Order with Id {0} is now pending.", newOrder.Id));
        }
        public IHttpActionResult CreateOrder(int id, OrderBindingModel model)
        {
            if (model == null)
            {
                return BadRequest();
            }

            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            var meal = this.db.Meals.All().FirstOrDefault(m => m.Id == id);
            if (meal == null)
            {
                return NotFound();
            }

            var currUserId = User.Identity.GetUserId();
            var currUser = this.db.Users.Find(currUserId);

            var order = new Order()
            {
                Meal = meal,
                Quantity = model.Quantity,
                User = currUser,
                CreatedOn = DateTime.Now,
                OrderStatus = OrderStatus.Pending
            };
            
            db.Orders.Add(order);
            db.SaveChanges();

            return Ok();
        }
        public IHttpActionResult CreateOrders(int id, OrderBindingModel m)
        {
            if (User == null)
                return this.Unauthorized();

            if (!ModelState.IsValid)
                return this.BadRequest();

            if (!this.Data.Meals.Any(me => me.Id == id))
                return this.NotFound();

            var order = new Order
            {
                MealId = id,
                Quantity = m.Quantity,
                UserId = User.Identity.GetUserId(),
                CreatedOn = DateTime.Now,
                OrderStatus = OrderStatus.Pending
            };

            this.Data.Orders.Add(order);

            this.Data.SaveChanges();

            return this.Ok();
        }