Example #1
0
 // GET: api/Meals?userId=xyz
 public IEnumerable <MealDto> GetMeals(String userId)
 {
     if (userId == "current")
     {
         userId = User.Identity.GetUserId();
     }
     return(msvc.GetMeals(userId).Select(b => MealDto.FromMeal(b)));
 }
Example #2
0
        public IHttpActionResult GetMeal(long id)
        {
            var b = msvc.GetMeal(id);

            if (b == null)
            {
                return(NotFound());
            }
            return(Ok(MealDto.FromMeal(b)));
        }
Example #3
0
        public IHttpActionResult PostMeal(Meal m)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            msvc.CreateMeal(m);
            uow.Save();

            return(CreatedAtRoute("DefaultApi", new { id = m.ID }, MealDto.FromMeal(m)));
        }
Example #4
0
 // GET: api/Meals
 public IEnumerable <MealDto> GetMeals()
 {
     return(msvc.GetMeals().Select(b => MealDto.FromMeal(b)));
 }