示例#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);
        }
        // parameter is the EF Restuarant model
        public static RestaurantLibrary.Models.Restaurant DataToLibrary(RestuarantReviewDataLayer.Restaurant data)
        {
            List <RestaurantLibrary.Models.Review> emptyList = new List <RestaurantLibrary.Models.Review>();

            // convert data Review to model Review
            foreach (RestuarantReviewDataLayer.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);
        }
 public ActionResult Create(RestaurantLibrary.Models.Restaurant res)
 {
     resCrud.AddRestaurant(res);
     return RedirectToAction("Index");
 }
示例#4
0
 public void UpdateRestaurantById(RestaurantLibrary.Models.Restaurant res)
 {
     RestaurantReviewDataLayer.Restaurant dalRest = restHelper.LibraryToData(res);
     dalCrud.UpdateRestaurantById(dalRest);
 }
示例#5
0
 public void AddRestaurant(RestaurantLibrary.Models.Restaurant res)
 {
     RestaurantReviewDataLayer.Restaurant dalRest = restHelper.LibraryToData(res);
     dalCrud.AddRestaurant(dalRest);
 }
示例#6
0
 public RestaurantLibrary.Models.Restaurant GetRestaurantById(int id)
 {
     RestaurantReviewDataLayer.Restaurant dllRest = dalCrud.GetRestaurantById(id);
     RestaurantLibrary.Models.Restaurant  bllRest = restHelper.DataToLibrary(dllRest);
     return(bllRest);
 }