Пример #1
0
 public static RestaurantReviewData.Restaurant ResObjToDB(Models.Restaurant objRest)
 {
     RestaurantReviewData.Restaurant DBRest = new RestaurantReviewData.Restaurant()
     {
         ID        = objRest.ID,
         Name      = objRest.Name,
         Address   = objRest.Address,
         City      = objRest.City,
         Country   = objRest.Country,
         ZIP       = objRest.ZIP,
         AvgRating = objRest.AvgRating,
         Reviews   = new List <RestaurantReviewData.Review>()
     };
     foreach (Models.Review r in objRest.Reviews)
     {
         DBRest.Reviews.Add(RevObjToDB(r));
     }
     return(DBRest);
 }
Пример #2
0
 public static Models.Restaurant DBToResObject(RestaurantReviewData.Restaurant DBRestaurant)
 {
     Models.Restaurant restObj = new Models.Restaurant()
     {
         ID        = DBRestaurant.ID,
         Name      = DBRestaurant.Name,
         Address   = DBRestaurant.Address,
         City      = DBRestaurant.City,
         Country   = DBRestaurant.Country,
         ZIP       = DBRestaurant.ZIP,
         AvgRating = (double)DBRestaurant.AvgRating,
         Reviews   = new List <Models.Review>()
     };
     foreach (RestaurantReviewData.Review r in DBRestaurant.Reviews)
     {
         restObj.Reviews.Add(DBToRevObj(r));
     }
     return(restObj);
 }