Example #1
0
        public static void EditRestaurant(int id, RestaurantModels.Restaurant restaurant)
        {
            var rest   = db.Restaurants.ToList();
            var select = rest.Find(x => x.ID.Equals(id));

            if (restaurant.Name != null && restaurant.Name != "")
            {
                select.Name = restaurant.Name;
            }
            if (restaurant.City != null && restaurant.City != "")
            {
                select.City = restaurant.City;
            }
            if (restaurant.State != null && restaurant.State != "")
            {
                select.State = restaurant.State;
            }
            if (restaurant.FoodType != null & restaurant.FoodType != "")
            {
                select.FoodType = restaurant.FoodType;
            }
            if (restaurant.OperationHours != null && restaurant.OperationHours != "")
            {
                select.OperationHours = restaurant.OperationHours;
            }

            db.SaveChanges();
        }
Example #2
0
 public static void AddNewRestaurnt(RestaurantModels.Restaurant restaurant)
 {
     //using (RReviewsEntities db = new RReviewsEntities())
     {
         db.Restaurants.Add(LibraryToData(restaurant));
         db.SaveChanges();
     }
 }
Example #3
0
 public static void DeleteRestaurnt(RestaurantModels.Restaurant restaurant)
 {
     //using (RReviewsEntities db = new RReviewsEntities())
     {
         var rest = db.Restaurants.ToList();
         db.Restaurants.Remove(rest.Find(x => x.ID.Equals(restaurant.ID)));
         db.SaveChanges();
     }
 }
Example #4
0
 public static double GetAvgReview(RestaurantModels.Restaurant restaurant)
 {
     //using (RReviewsEntities db = new RReviewsEntities())
     {
         var reviews  = db.Reviews.ToList();
         var lreviews = reviews.FindAll((x => x.RestaurantID.Equals(restaurant.ID)));
         return(Math.Round(lreviews.Select(x => x.ReviewerRating).Average(), 2));
     }
 }
        public static RestaurantModels.Restaurant DataToLibraryRestaurant(Restaurant dataModel)
        {
            var libModel = new RestaurantModels.Restaurant(dataModel.Name, dataModel.City, dataModel.State)
            {
                ID             = dataModel.ID,
                FoodType       = dataModel.FoodType,
                OperationHours = dataModel.OperationHours,
                Reviews        = new List <RestaurantModels.Review>()
            };

            foreach (var item in dataModel.Reviews)
            {
                libModel.Reviews.Add(DataToLibraryReview(item));
            }
            return(libModel);
        }
Example #6
0
        public static Restaurant LibraryToData(RestaurantModels.Restaurant libModel)
        {
            var dataModel = new Restaurant()
            {
                ID             = libModel.ID,
                Name           = libModel.Name,
                City           = libModel.City,
                State          = libModel.State,
                FoodType       = libModel.FoodType,
                OperationHours = libModel.OperationHours,
                Reviews        = new List <Review>()
            };

            foreach (var item in libModel.Reviews)
            {
                dataModel.Reviews.Add(LibraryToData(item));
            }
            return(dataModel);
        }
Example #7
0
 public static double GetAvgReview(RestaurantModels.Restaurant restaurant)
 {
     return(RestaurantAccessData.GetAvgReview(restaurant));
 }
Example #8
0
 public static void AddNewRestaurnt(RestaurantModels.Restaurant restaurant)
 {
     RestaurantAccessData.AddNewRestaurnt(restaurant);
 }
 public static void EditRestaurant(int id, RestaurantModels.Restaurant restaurant)
 {
     RestaurantAccessData.EditRestaurant(id, restaurant);
 }
 public static void DeleteRestaurant(RestaurantModels.Restaurant restaurant)
 {
     RestaurantAccessData.DeleteRestaurnt(restaurant);
 }