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"); }
public void UpdateRestaurantById(RestaurantLibrary.Models.Restaurant res) { RestaurantReviewDataLayer.Restaurant dalRest = restHelper.LibraryToData(res); dalCrud.UpdateRestaurantById(dalRest); }
public void AddRestaurant(RestaurantLibrary.Models.Restaurant res) { RestaurantReviewDataLayer.Restaurant dalRest = restHelper.LibraryToData(res); dalCrud.AddRestaurant(dalRest); }
public RestaurantLibrary.Models.Restaurant GetRestaurantById(int id) { RestaurantReviewDataLayer.Restaurant dllRest = dalCrud.GetRestaurantById(id); RestaurantLibrary.Models.Restaurant bllRest = restHelper.DataToLibrary(dllRest); return(bllRest); }