public bool DeleteEvaluation(Evaluation_ evaluation)
 {
     using (MFDatabaseEntities moodFullDb = new MFDatabaseEntities())
     {
         try
         {
             int        evaluationID = Convert.ToInt32(evaluation.EvaluationId);
             Evaluation xe           = moodFullDb.Evaluations.Single(x => x.EvaluationId == evaluationID);
             moodFullDb.Evaluations.Remove(xe);
             moodFullDb.SaveChanges();
             return(true);
         }
         catch
         {
             return(false);
         }
     }
 }
Exemple #2
0
 public bool DeleteUser(User_ user)
 {
     using (MFDatabaseEntities moodFullDb = new MFDatabaseEntities())
     {
         try
         {
             int  usernameID = Convert.ToInt32(user.UserId);
             User xe         = moodFullDb.Users.Single(x => x.UserId == usernameID);
             moodFullDb.Users.Remove(xe);
             moodFullDb.SaveChanges();
             return(true);
         }
         catch
         {
             return(false);
         }
     }
 }
 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);
         }
     }
 }
 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);
         }
     };
 }
 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);
         }
     }
 }
Exemple #6
0
 public bool EditUser(User_ user)
 {
     using (MFDatabaseEntities moodFullDb = new MFDatabaseEntities())
     {
         try
         {
             int  usernameId = Convert.ToInt32(user.UserId);
             User xe         = moodFullDb.Users.Single(x => x.UserId == usernameId);
             xe.Username  = user.Username;
             xe.Password  = user.Password;
             xe.FirstName = user.FirstName;
             xe.LastName  = user.LastName;
             xe.UserType  = user.UserType;
             moodFullDb.SaveChanges();
             return(true);
         }
         catch
         {
             return(false);
         }
     };
 }
Exemple #7
0
 public bool CreateUser(User_ user)
 {
     using (MFDatabaseEntities moodFullDb = new MFDatabaseEntities())
     {
         try
         {
             User xe = new User();
             xe.Username  = user.Username;
             xe.Password  = user.Password;
             xe.FirstName = user.FirstName;
             xe.LastName  = user.LastName;
             xe.UserType  = user.UserType;
             moodFullDb.Users.Add(xe);
             moodFullDb.SaveChanges();
             return(true);
         }
         catch
         {
             return(false);
         }
     }
 }
 public bool EditEvaluation(Evaluation_ evaluation)
 {
     using (MFDatabaseEntities moodFullDb = new MFDatabaseEntities())
     {
         try
         {
             int        evaluationId = Convert.ToInt32(evaluation.EvaluationId);
             Evaluation xe           = moodFullDb.Evaluations.Single(x => x.EvaluationId == evaluationId);
             xe.UserId       = evaluation.UserId;
             xe.RestaurantId = evaluation.RestaurantId;
             xe.MoodRating   = evaluation.MoodRating;
             xe.Price        = evaluation.Price;
             xe.Experience   = evaluation.Experience;
             moodFullDb.SaveChanges();
             return(true);
         }
         catch
         {
             return(false);
         }
     };
 }
 public bool CreateEvaluation(Evaluation_ evaluation)
 {
     using (MFDatabaseEntities moodFullDb = new MFDatabaseEntities())
     {
         try
         {
             Evaluation xe = new Evaluation();
             xe.UserId       = evaluation.UserId;
             xe.RestaurantId = evaluation.RestaurantId;
             xe.MoodRating   = evaluation.MoodRating;
             xe.Price        = evaluation.Price;
             xe.Experience   = evaluation.Experience;
             moodFullDb.Evaluations.Add(xe);
             moodFullDb.SaveChanges();
             return(true);
         }
         catch
         {
             return(false);
         }
     }
 }