示例#1
0
 public void RemoveUserRateFromDB(int userId, int movieId)
 {
     using (mov4eEntities context = new mov4eEntities())
     {
         context.Ratings.Remove(context.Ratings.Where(r => r.user_Id == userId && r.movie_Id == movieId).Single());
         context.SaveChanges();
     }
 }
示例#2
0
 public void UpdatePass(string userName, string newPass)
 {
     using (mov4eEntities context = new mov4eEntities())
     {
         context.Users.Where(u => u.userName == userName).Single().password = newPass;
         context.SaveChanges();
     }
 }
示例#3
0
 // This is a private method that edits the summary of a certain Movie.
 private void EditSummary(int id, string summary)
 {
     using (mov4eEntities m = new mov4eEntities())
     {
         var updateQuery = (Movie)m.Movies.Find(id);
         updateQuery.summary = summary;
         m.SaveChanges();
     }
 }
 public void ChangeUserName(int id, string userName)
 {
     using (var context = new mov4eEntities())
     {
         User CurrentUser = context.Users.First(u => u.id.Equals(id));
         CurrentUser.userName = userName;
         context.SaveChanges();
     }
 }
示例#5
0
 // This is a private method that edits the duration of a certain Movie.
 private void EditDuration(int id, int dur)
 {
     using (mov4eEntities m = new mov4eEntities())
     {
         var updateQuery = (Movie)m.Movies.Find(id);
         updateQuery.duration = dur;
         m.SaveChanges();
     }
 }
示例#6
0
 public void AddToWatchList(int movieId, int userId)
 {
     using (mov4eEntities context = new mov4eEntities())
     {
         User currentUser = context.Users.Find(userId);
         currentUser.movies.Add(context.Movies.Find(movieId));
         context.SaveChanges();
     }
 }
示例#7
0
 // This is a private method that edits the prime date of a certain Movie.
 private void EditYear(int id, Nullable <DateTime> year)
 {
     using (mov4eEntities m = new mov4eEntities())
     {
         var updateQuery = (Movie)m.Movies.Find(id);
         updateQuery.year = year;
         m.SaveChanges();
     }
 }
 public void ChangeAge(int id, int age)
 {
     using (var context = new mov4eEntities())
     {
         UserInfo CurrentUserInfo = context.UserInfoes.First(uf => uf.id.Equals(id));
         CurrentUserInfo.age = age;
         context.SaveChanges();
     }
 }
示例#9
0
 // This is a private method that edits the genre of a certain Movie.
 private void EditGenre(int id, int genre)
 {
     using (mov4eEntities m = new mov4eEntities())
     {
         var updateQuery = (Movie)m.Movies.Find(id);
         updateQuery.genre = genre;
         m.SaveChanges();
     }
 }
示例#10
0
 // This is a private method that edits the parental guidance of a certain Movie.
 private void EditPg(int id, int pg)
 {
     using (mov4eEntities m = new mov4eEntities())
     {
         var updateQuery = (Movie)m.Movies.Find(id);
         updateQuery.pg = pg;
         m.SaveChanges();
     }
 }
示例#11
0
 // This is a private method that edits the picture of a certain Movie.
 private void EditPicture(int id, byte[] pic)
 {
     using (mov4eEntities m = new mov4eEntities())
     {
         var updateQuery = (Movie)m.Movies.Find(id);
         updateQuery.picture = pic;
         m.SaveChanges();
     }
 }
示例#12
0
 public void ChangePassword(int id, string newPass)
 {
     using (var context = new mov4eEntities())
     {
         User CurrentUser = context.Users.First(u => u.id.Equals(id));
         CurrentUser.password = newPass;
         context.SaveChanges();
     }
 }
示例#13
0
 // This is a private method that edits the title of a certain Movie.
 private void EditTitle(int id, string title)
 {
     using (mov4eEntities m = new mov4eEntities())
     {
         var updateQuery = (Movie)m.Movies.Find(id);
         updateQuery.title = title;
         m.SaveChanges();
     }
 }
示例#14
0
 public void ChangeProfilePicture(int id, byte[] profilePic)
 {
     using (var context = new mov4eEntities())
     {
         UserInfo CurrentUser = context.UserInfoes.First(cU => cU.id.Equals(id));
         CurrentUser.picture = profilePic;
         context.SaveChanges();
     }
 }
示例#15
0
 public void ChangeGender(int id, string gender)
 {
     using (var context = new mov4eEntities())
     {
         UserInfo CurrentUserInfo = context.UserInfoes.First(uf => uf.id.Equals(id));
         CurrentUserInfo.gender = gender;
         context.SaveChanges();
     }
 }
示例#16
0
 public void ChangeMail(int id, string Mail)
 {
     using (var context = new mov4eEntities())
     {
         UserInfo CurrentUserInfo = context.UserInfoes.First(uf => uf.id.Equals(id));
         CurrentUserInfo.email = Mail;
         context.SaveChanges();
     }
 }
示例#17
0
 public void ChangeLastName(int id, string lastName)
 {
     using (var context = new mov4eEntities())
     {
         UserInfo CurrentUserInfo = context.UserInfoes.First(uf => uf.id.Equals(id));
         CurrentUserInfo.lastName = lastName;;
         context.SaveChanges();
     }
 }
示例#18
0
 public void SaveUser(User newUser, UserInfo newUserInfo)
 {
     using (var context = new mov4eEntities())
     {
         context.Users.Add(newUser);
         context.UserInfoes.Add(newUserInfo);
         context.SaveChanges();
     }
 }
示例#19
0
 //This method removes movie from watchlist
 public void RemoveFromWatchList(int userId, int movieId)
 {
     using (var context = new mov4eEntities())
     {
         User  us = context.Users.Find(userId);
         Movie mv = context.Movies.Find(movieId);
         us.movies.Remove(mv);
         context.SaveChanges();
     }
 }
示例#20
0
 public void InserNewRate(int movieId, int userId, int rate)
 {
     using (mov4eEntities context = new mov4eEntities())
     {
         context.Ratings.Add(new Rating()
         {
             user_Id = userId, movie_Id = movieId, userRating = rate
         });
         context.SaveChanges();
     }
 }
示例#21
0
        /// <summary>
        /// The <c>SaveMovie</c> method saves the movie in the database.
        /// </summary>
        public void SaveMovie()
        {
            List <Movie> movies = new List <Movie>();

            using (mov4eEntities context = new mov4eEntities())
            {
                movies.Add(movie);
                context.Movies.Add(movie);
                context.SaveChanges();
            }
        }
示例#22
0
 public void DeleteComentsCounter(int count)
 {
     using (mov4eEntities context = new mov4eEntities())
     {
         List <Comment> comms = context.Comments.OrderByDescending(c => c.id).Take(count).ToList();
         foreach (Comment el in comms)
         {
             context.Comments.Remove(el);
         }
         context.SaveChanges();
     }
 }
示例#23
0
        public void DeleteCommentFromDB(List <int> commentsIds)
        {
            using (mov4eEntities context = new mov4eEntities())
            {
                foreach (int el in commentsIds)
                {
                    Comment com = context.Comments.Where(c => c.id == el).Single();
                    context.Comments.Remove(com);
                }

                context.SaveChanges();
            }
        }
示例#24
0
 public void SaveComment(int userId, int movieId, string comment)
 {
     using (mov4eEntities context = new mov4eEntities())
     {
         context.Comments.Add(new Comment()
         {
             user_Id          = userId,
             movie_Id         = movieId,
             comment1         = comment,
             dateOfTheComment = DateTime.Now
         });
         context.SaveChanges();
     }
 }
示例#25
0
 /// <summary>
 /// The <c>DeleteMovie()</c> method deletes a certain Movie by its id.
 /// </summary>
 /// <param name="id">This is the id of a certain Movie.</param>
 /// <exception cref="Mov4e.Exceptions.NotFoundSuchItemException">Thrown when the id of the Movie
 /// that we want to delete is invalid.</exception>
 /// <remarks>When the exception is thrown the method writes it in a log file called errors.txt</remarks>
 public void DeleteMovie(int id)
 {
     using (mov4eEntities context = new mov4eEntities())
     {
         var deleteQuery = context.Movies.Find(id);
         if (deleteQuery != null)
         {
             context.Movies.Remove(deleteQuery);
             context.SaveChanges();
         }
         else
         {
             Logger.Logger.WriteToLogFile(DateTime.Now.ToString()
                                          + " The item which you want to delete is not found!" + "\n"
                                          + new NotFoundSuchItemException().ToString());
             throw new NotFoundSuchItemException();
         }
     }
 }