public int LastMovieId() { using (mov4eEntities context = new mov4eEntities()) { return(context.Movies.OrderByDescending(m => m.id).First().id); } }
public string GetUserNameForCurrentUserFromDB(int userId) { using (mov4eEntities context = new mov4eEntities()) { return(context.Users.Find(userId).userName); } }
public string UserPosition(int userId) { using (mov4eEntities context = new mov4eEntities()) { return(context.UserInfoes.Find(userId).position); } }
public bool checkIfUserIsInDB(string username) { using (mov4eEntities context = new mov4eEntities()) { return(context.Users.Any(u => u.userName == username)); } }
public bool isRateInDB(int userId, int movieId) { using (mov4eEntities context = new mov4eEntities()) { bool containsRate = context.Ratings.Any(rt => rt.movie_Id == movieId && rt.user_Id == userId); return(containsRate); } }
public double?GetRateByMovieId(int movieId) { using (mov4eEntities context = new mov4eEntities()) { double?rate = context.Movies.Find(movieId).AVGRating; return(rate); } }
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 string GetGenreById(int id) { using (mov4eEntities context = new mov4eEntities()) { Genre ge = context.Genres.Find(id); return(ge.name); } }
/// <summary> /// The <c>GetMoviesTitles()</c> method gets a list of all movies' titles. /// </summary> /// <returns>The method returns the all movies' titles.</returns> public List <string> GetMoviesTitles() { using (mov4eEntities context = new mov4eEntities()) { var titlesQuery = from m in context.Movies select m.title; return(titlesQuery.ToList <string>()); } }
public Movie GetMovieById(int id) { using (mov4eEntities context = new mov4eEntities()) { Movie mv = context.Movies.Find(id); return(mv); } }
public void UpdatePass(string userName, string newPass) { using (mov4eEntities context = new mov4eEntities()) { context.Users.Where(u => u.userName == userName).Single().password = newPass; context.SaveChanges(); } }
/// <summary> /// The <c>GetMovieGenre()</c> method gets a certain's Movie's genre as /// a number(id from the database) by its name. /// </summary> /// <param name="gen">This is the genre's name.</param> /// <returns>This method returns the id of a certain genre.</returns> public int GetMovieGenre(string gen) { using (mov4eEntities context = new mov4eEntities()) { var genre = (from genr in context.Genres where genr.name == gen select genr.id).First(); return(genre); } }
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(); } }
// 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(); } }
public void SaveUser(User newUser, UserInfo newUserInfo) { using (var context = new mov4eEntities()) { context.Users.Add(newUser); context.UserInfoes.Add(newUserInfo); context.SaveChanges(); } }
//Returns Movie title for Wtchlist public string GetMovieTitle(int movieId) { using (var context = new mov4eEntities()) { Movie mv = context.Movies.Find(movieId); return(mv.title); } }
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(); } }
public string GetEmailForUser(string userName) { using (mov4eEntities context = new mov4eEntities()) { string email = context.Users.Where(c => c.userName == userName).Single().user_info.email.ToString(); return(email); } }
public string GetCurrentUserPosition(string username) { using (mov4eEntities context = new mov4eEntities()) { string position = context.Users.Where(c => c.userName == username).FirstOrDefault().user_info.position; return(position); } }
public int GetCurrentUserID(string username) { using (mov4eEntities context = new mov4eEntities()) { int ID = context.Users.Where(c => c.userName == username).FirstOrDefault().id; return(ID); } }
// 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(); } }
public string GetPasswordForUser(string username) { using (mov4eEntities context = new mov4eEntities()) { string password = context.Users.Where(c => c.userName == username).FirstOrDefault().password; return(password); } }
// 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(); } }
// 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 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(); } }
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 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 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 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(); } }