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(); } }
public void UpdatePass(string userName, string newPass) { using (mov4eEntities context = new mov4eEntities()) { context.Users.Where(u => u.userName == userName).Single().password = newPass; context.SaveChanges(); } }
// 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(); } }
// 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(); } }
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(); } }
// 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(); } }
// 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(); } }
// 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(); } }
// 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(); } }
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(); } }
// 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(); } }
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(); } }
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(); } }
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(); } }
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(); } }
public void SaveUser(User newUser, UserInfo newUserInfo) { using (var context = new mov4eEntities()) { context.Users.Add(newUser); context.UserInfoes.Add(newUserInfo); context.SaveChanges(); } }
//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(); } }
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(); } }
/// <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(); } }
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(); } }
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(); } }
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(); } }
/// <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(); } } }