// 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))); }
public IHttpActionResult GetMeal(long id) { var b = msvc.GetMeal(id); if (b == null) { return(NotFound()); } return(Ok(MealDto.FromMeal(b))); }
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))); }
// GET: api/Meals public IEnumerable <MealDto> GetMeals() { return(msvc.GetMeals().Select(b => MealDto.FromMeal(b))); }