예제 #1
0
 public bool DeleteRestaurant(Restaurant_ restaurant)
 {
     using (MFDatabaseEntities moodFullDb = new MFDatabaseEntities())
     {
         try
         {
             int        restaurantID = Convert.ToInt32(restaurant.RestaurantId);
             Restaurant xe           = moodFullDb.Restaurants.Single(x => x.RestaurantId == restaurantID);
             moodFullDb.Restaurants.Remove(xe);
             moodFullDb.SaveChanges();
             return(true);
         }
         catch
         {
             return(false);
         }
     }
 }
예제 #2
0
 public bool EditRestaurant(Restaurant_ restaurant)
 {
     using (MFDatabaseEntities moodFullDb = new MFDatabaseEntities())
     {
         try
         {
             int        restaurantId = Convert.ToInt32(restaurant.RestaurantId);
             Restaurant xe           = moodFullDb.Restaurants.Single(x => x.RestaurantId == restaurantId);
             xe.Name          = restaurant.Name;
             xe.AvgMood       = restaurant.AvgMood;
             xe.AvgPrice      = restaurant.AvgPrice;
             xe.AvgExperience = restaurant.AvgExperience;
             moodFullDb.SaveChanges();
             return(true);
         }
         catch
         {
             return(false);
         }
     };
 }
예제 #3
0
 public bool CreateRestaurant(Restaurant_ restaurant)
 {
     using (MFDatabaseEntities moodFullDb = new MFDatabaseEntities())
     {
         try
         {
             Restaurant xe = new Restaurant();
             xe.Name          = restaurant.Name;
             xe.AvgMood       = restaurant.AvgMood;
             xe.AvgPrice      = restaurant.AvgPrice;
             xe.AvgExperience = restaurant.AvgExperience;
             moodFullDb.Restaurants.Add(xe);
             moodFullDb.SaveChanges();
             return(true);
         }
         catch
         {
             return(false);
         }
     }
 }