Beispiel #1
0
        public RestaurantReviewDataLayer.Restaurant LibraryToData(RestaurantLibrary.Models.Restaurant data)
        {
            List <RestaurantReviewDataLayer.Review> emptyList = new List <RestaurantReviewDataLayer.Review>();
            ReviewHelper reviewHelper = new ReviewHelper();

            // convert data Review to model Review
            if (data.Reviewlist != null)
            {
                foreach (RestaurantLibrary.Models.Review rev in data.Reviewlist)
                {
                    emptyList.Add(reviewHelper.LibraryToData(rev));
                }
            }


            var libModel = new RestaurantReviewDataLayer.Restaurant()
            {
                Name     = data.Name,
                location = data.Location,
                Reviews  = emptyList,
                ID       = data.id
            };

            return(libModel);
        }
Beispiel #2
0
        // parameter is the EF Restuarant model
        public RestaurantLibrary.Models.Restaurant DataToLibrary(RestaurantReviewDataLayer.Restaurant data)
        {
            List <RestaurantLibrary.Models.Review> emptyList = new List <RestaurantLibrary.Models.Review>();
            ReviewHelper reviewHelper = new ReviewHelper();


            // convert data Review to model Review
            foreach (RestaurantReviewDataLayer.Review rev in data.Reviews)
            {
                emptyList.Add(reviewHelper.DataToLibrary(rev));
            }

            var libModel = new RestaurantLibrary.Models.Restaurant()
            {
                Name       = data.Name,
                Location   = data.location,
                Reviewlist = emptyList,
                id         = data.ID
            };

            return(libModel);
        }
Beispiel #3
0
 public void UpdateRestaurantById(RestaurantLibrary.Models.Restaurant res)
 {
     RestaurantReviewDataLayer.Restaurant dalRest = restHelper.LibraryToData(res);
     dalCrud.UpdateRestaurantById(dalRest);
 }
Beispiel #4
0
 public void AddRestaurant(RestaurantLibrary.Models.Restaurant res)
 {
     RestaurantReviewDataLayer.Restaurant dalRest = restHelper.LibraryToData(res);
     dalCrud.AddRestaurant(dalRest);
 }
Beispiel #5
0
 public RestaurantLibrary.Models.Restaurant GetRestaurantById(int id)
 {
     RestaurantReviewDataLayer.Restaurant dllRest = dalCrud.GetRestaurantById(id);
     RestaurantLibrary.Models.Restaurant  bllRest = restHelper.DataToLibrary(dllRest);
     return(bllRest);
 }