Example #1
0
 public User GetUser(string login, byte[] hash)
 {
     using (MoviesDb db = new MoviesDb())
     {
         return(db.Users.Include("Role").FirstOrDefault(u => u.Name == login && u.Password == hash));
     }
 }
Example #2
0
 public void AddMovie(Movie movie, User user)
 {
     using (MoviesDb db = new MoviesDb())
     {
         db.Movies.Add(movie).User = user;
         db.SaveChanges();
     }
 }
Example #3
0
        public List <Movie> GetMovies()
        {
            List <Movie> movies = null;

            using (MoviesDb db = new MoviesDb())
            {
                movies = db.Movies.ToList();
            }
            return(movies);
        }
Example #4
0
 public void RemoveMovie(Movie movie)
 {
     using (MoviesDb db = new MoviesDb())
     {
         Movie removedMovie = db.Movies.FirstOrDefault(m => m.Id == movie.Id);
         if (removedMovie != null)
         {
             db.Movies.Remove(removedMovie);
             db.SaveChanges();
         }
     }
 }
Example #5
0
 public void EditMovie(Movie movie)
 {
     using (MoviesDb db = new MoviesDb())
     {
         Movie editedMovie = db.Movies.FirstOrDefault(m => m.Id == movie.Id);
         if (editedMovie != null)
         {
             editedMovie.Name    = movie.Name;
             editedMovie.Picture = movie.Picture;
             editedMovie.Rating  = movie.Rating;
             editedMovie.Year    = movie.Year;
             db.SaveChanges();
         }
     }
 }