示例#1
0
 public int LastMovieId()
 {
     using (mov4eEntities context = new mov4eEntities())
     {
         return(context.Movies.OrderByDescending(m => m.id).First().id);
     }
 }
示例#2
0
 public string GetUserNameForCurrentUserFromDB(int userId)
 {
     using (mov4eEntities context = new mov4eEntities())
     {
         return(context.Users.Find(userId).userName);
     }
 }
示例#3
0
 public string UserPosition(int userId)
 {
     using (mov4eEntities context = new mov4eEntities())
     {
         return(context.UserInfoes.Find(userId).position);
     }
 }
示例#4
0
 public bool checkIfUserIsInDB(string username)
 {
     using (mov4eEntities context = new mov4eEntities())
     {
         return(context.Users.Any(u => u.userName == username));
     }
 }
示例#5
0
 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);
     }
 }
示例#6
0
 public double?GetRateByMovieId(int movieId)
 {
     using (mov4eEntities context = new mov4eEntities())
     {
         double?rate = context.Movies.Find(movieId).AVGRating;
         return(rate);
     }
 }
示例#7
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();
     }
 }
示例#8
0
 public string GetGenreById(int id)
 {
     using (mov4eEntities context = new mov4eEntities())
     {
         Genre ge = context.Genres.Find(id);
         return(ge.name);
     }
 }
示例#9
0
 /// <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>());
     }
 }
示例#10
0
 public Movie GetMovieById(int id)
 {
     using (mov4eEntities context = new mov4eEntities())
     {
         Movie mv = context.Movies.Find(id);
         return(mv);
     }
 }
示例#11
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();
     }
 }
示例#12
0
 /// <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);
     }
 }
示例#13
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();
     }
 }
示例#14
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();
     }
 }
示例#15
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();
     }
 }
示例#16
0
 public void SaveUser(User newUser, UserInfo newUserInfo)
 {
     using (var context = new mov4eEntities())
     {
         context.Users.Add(newUser);
         context.UserInfoes.Add(newUserInfo);
         context.SaveChanges();
     }
 }
示例#17
0
        //Returns Movie title for Wtchlist
        public string GetMovieTitle(int movieId)
        {
            using (var context = new mov4eEntities())
            {
                Movie mv = context.Movies.Find(movieId);

                return(mv.title);
            }
        }
示例#18
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();
     }
 }
示例#19
0
        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);
            }
        }
示例#20
0
        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);
            }
        }
示例#21
0
        public int GetCurrentUserID(string username)
        {
            using (mov4eEntities context = new mov4eEntities())
            {
                int ID = context.Users.Where(c => c.userName == username).FirstOrDefault().id;

                return(ID);
            }
        }
示例#22
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();
     }
 }
示例#23
0
        public string GetPasswordForUser(string username)
        {
            using (mov4eEntities context = new mov4eEntities())
            {
                string password = context.Users.Where(c => c.userName == username).FirstOrDefault().password;

                return(password);
            }
        }
示例#24
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();
     }
 }
示例#25
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();
     }
 }
示例#26
0
 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();
     }
 }
示例#27
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();
     }
 }
示例#28
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();
     }
 }
示例#29
0
 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();
     }
 }
示例#30
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();
     }
 }