Пример #1
0
 public IHttpActionResult Get(int id)
 {
     try
     {
         using (var db = new RestaurantContext())
         {
             DishCE d  = new DishCE();
             Dish   d1 = new Dish();
             d1         = db.DishDetail(id).FirstOrDefault();
             d.ID       = d1.ID;
             d.Name     = d1.Name;
             d.ImageURL = d1.ImageURL;
             d.Area     = d1.Area;
             d.Cooking  = d1.Cooking;
             CategoryCE c  = new CategoryCE();
             Category   c1 = db.DishCategory(d1.ID_Category).FirstOrDefault();
             c.ID          = c1.ID;
             c.Name        = c1.Name;
             c.ImageURL    = c1.ImageURL;
             d.Category    = c;
             d.Ingredients = db.DishIngredients(id).ToList();
             d.Tags        = db.DishTags(id).ToList();
             return(Ok(d));
         }
     }
     catch (Exception e)
     {
         return(Content(HttpStatusCode.BadRequest, e.Message));
     }
 }