public IEnumerable<OrderMovie> GetAllOrderMoviesByOrder(Order item)
 {
     using (Context mCon = new Context())
     {
         return mCon.OrderMovie.Include("Movie.Genres").Include("Order").Where(x => x.Order.Id == item.Id).ToList();
     }
 }
 public Movie GetMovieByOrderMovie(OrderMovie item)
 {
     using (Context mCon = new Context())
     {
         return mCon.OrderMovie.Include("Movie.Genres").Include("Order").Where(x => x.Id == item.Id).FirstOrDefault().Movie;
     }
 }
 public IEnumerable<OrderMovie> GetAll()
 {
     using (Context mCon = new Context())
     {
         return mCon.OrderMovie.Include("Order").Include("Movie.Genres").ToList();
     }
 }
 public IEnumerable<Movie> GetAll()
 {
     using (Context mCon = new Context())
     {
         return mCon.Movies.Include("Genres").ToList();
     }
 }
 public Genre Get(int id)
 {
     using (Context mCon = new Context())
     {
         return mCon.Genres.FirstOrDefault(x => x.Id == id);
     }
 }
 public IEnumerable<Login> GetAll()
 {
     using (Context mCon = new Context())
     {
         return mCon.Login.Include("Customer").ToList();
     }
 }
 public Order Get(int id)
 {
     using (Context mCon = new Context())
     {
         return mCon.Orders.Include("OrderMovie").Include("Customer").FirstOrDefault(x => x.Id == id);
     }
 }
 public OrderMovie Get(int id)
 {
     using (Context mCon = new Context())
     {
         return mCon.OrderMovie.Include("Order").Include("Movie.Genres").FirstOrDefault(x => x.Id == id);
     }
 }
 public IEnumerable<Genre> GetAll()
 {
     using (Context mCon = new Context())
     {
         return mCon.Genres.ToList();
     }
 }
Example #10
0
 public Login Get(String username)
 {
     using (Context mCon = new Context())
     {
         return mCon.Login.Include("Customer").FirstOrDefault(x => x.Username == username);
     }
 }
Example #11
0
 public IEnumerable<Order> GetAll()
 {
     using (Context mCon = new Context())
     {
         return mCon.Orders.Include("OrderMovie").Include("Customer").ToList();
     }
 }
Example #12
0
 public Movie Get(int id)
 {
     using (Context mCon = new Context())
     {
         return mCon.Movies.Include("Genres").FirstOrDefault(x => x.Id == id);
     }
 }
Example #13
0
 public Movie Add(Movie item)
 {
     if (item == null)
         throw new ArgumentNullException("movie is null");
     if (item.Name == null)
         throw new ArgumentException("FirstName can not be null");
     using (Context mCon = new Context())
     {
         if (item.Genres.Count > 0)
         {
             List<Genre> temp = new List<Genre>();
             bool found = false;
             foreach (var gen in item.Genres.ToList())
             {
                 found = false;
                 foreach (var item2 in mCon.Genres.ToList())
                 {
                     if (gen.Id == item2.Id)
                     {
                         temp.Add(item2);
                         found = true;
                     }
                 }
                 if (!found)
                     temp.Add(gen);
             }
             item.Genres = temp;
         }
         item = mCon.Movies.Add(item);
         mCon.SaveChanges();
     }
     return item;
 }
Example #14
0
 public Customer GetCustomerByLoginUsername(string item)
 {
     using (Context mCon = new Context())
     {
         if (mCon.Login.Where(x => x.Username.Equals(item)).FirstOrDefault() != null)
             return mCon.Login.Include("Customer").FirstOrDefault(x => x.Username.Equals(item)).Customer;
         return null;
     }
 }
Example #15
0
 public IEnumerable<Genre> GetGenreByMovie(Movie mov)
 {
     if (mov == null)
         throw new ArgumentNullException("Movie can not be null");
     using (Context mCon = new Context())
     {
         return mCon.Movies.Include("Genres").FirstOrDefault(x => x.Id == mov.Id).Genres.ToList();
     }
 }
Example #16
0
 public IEnumerable<Order> GetOrdersByCustomer(Customer item)
 {
     if (item == null)
         throw new ArgumentNullException("Customer can not be null");
     using (Context mCon = new Context())
     {
         return mCon.Orders.Include("Customer").Include("OrderMovie").Where(x => x.Customer.Id == item.Id).ToList();
     }
 }
 public void Remove(int id)
 {
     using (Context mCon = new Context())
     {
         OrderMovie ord = mCon.OrderMovie.Where(x => x.Id == id).FirstOrDefault();
         mCon.OrderMovie.Remove(ord);
         mCon.SaveChanges();
     }
 }
        public void Genre_added_on_call_test()
        {
            Genre temp = new Genre() { Name = "test" };
            Facade facade = new Facade();
            temp = facade.GetGenreRepo().Add(temp);
            Context context = new Context();

            Assert.IsNotNull(context.Genres.FirstOrDefault(x=> x.Id == temp.Id));
            Assert.AreNotEqual(temp.Id, 0);
        }
        public void Movie_added_on_call_test()
        {
            Movie temp = new Movie() { Name = "test", Price = 120d, TrailerURL = "test" };
            Facade facade = new Facade();
            temp = facade.GetMovieRepo().Add(temp);
            Context context = new Context();

            Assert.IsNotNull(context.Movies.FirstOrDefault(x=>x.Id == temp.Id));
            Assert.AreNotEqual(temp.Id, 0);
        }
Example #20
0
 public void Remove(string username)
 {
     Login temp = Get(username);
     if (temp == null)
         throw new ArgumentNullException("Login is null");
     using (Context mCon = new Context())
     {
         mCon.Login.Attach(temp);
         mCon.Login.Remove(temp);
         mCon.SaveChanges();
     }
 }
Example #21
0
 public Login Add(Login item)
 {
     if (item == null)
         throw new ArgumentNullException("Login cant be null");
     using (Context mCon = new Context())
     {
         item.Customer = mCon.Customers.FirstOrDefault(x => x.Id == item.Customer.Id);
         item = mCon.Login.Add(item);
         mCon.SaveChanges();
     }
     return item;
 }
Example #22
0
 public void Remove(int id)
 {
     Order temp = Get(id);
     if (temp == null)
         throw new ArgumentNullException("Order is null");
     using (Context mCon = new Context())
     {
         mCon.Orders.Attach(temp);
         mCon.Orders.Remove(temp);
         mCon.SaveChanges();
     }
 }
Example #23
0
 public bool Update(Genre item)
 {
     if (item == null)
         throw new ArgumentNullException("Genre is null");
     if (Get(item.Id) == null)
         return false;
     using (Context mCon = new Context())
     {
         mCon.Entry(item).State = EntityState.Modified;
         mCon.SaveChanges();
     }
     return true;
 }
Example #24
0
 public Genre Add(Genre item)
 {
     if (item == null)
         throw new ArgumentNullException("Genre is null");
     if (item.Name == null)
         throw new ArgumentException("FirstName can not be null");
     using (Context mCon = new Context())
     {
         item = mCon.Genres.Add(item);
         mCon.SaveChanges();
     }
     return item;
 }
        public OrderMovie Add(OrderMovie item)
        {
            if (item == null)
                throw new ArgumentNullException("Ordermovie can not be null");
            using (Context mCon = new Context())
            {
                item.Movie = mCon.Movies.Where(x => x.Id == item.Movie.Id).FirstOrDefault();
                item.Order = mCon.Orders.Where(x => x.Id == item.Order.Id).FirstOrDefault();

                item = mCon.OrderMovie.Add(item);
                mCon.SaveChanges();
            }
            return item;
        }
 public bool Update(OrderMovie item)
 {
     if (item == null)
         throw new ArgumentNullException("OrderMovie is null");
     if (Get(item.Id) == null)
         return false;
     using (Context mCon = new Context())
     {
         OrderMovie temp = mCon.OrderMovie.FirstOrDefault(x => x.Id == item.Id);
         temp.Movie = item.Movie;
         temp.Order = item.Order;
         mCon.SaveChanges();
     }
     return true;
 }
Example #27
0
 public IEnumerable<Movie> GetMoviesByOrder(Order item)
 {
     if (item == null)
         throw new ArgumentNullException("Order can not be null");
     using (Context mCon = new Context())
     {
         List<OrderMovie> oms = mCon.OrderMovie.Include("Movie.Genres").Include("Order").Where(x => x.Order.Id == item.Id).ToList();
         List<Movie> movies = new List<Movie>();
         foreach (var i in oms)
         {
             movies.Add(i.Movie);
         }
         return movies;
     }
 }
Example #28
0
 public IEnumerable<Movie> GetMovieByGenre(Genre item)
 {
     if (item == null)
         throw new ArgumentNullException("Genre is null");
     using (Context mCon = new Context())
     {
         List<Movie> temp = new List<Movie>();
         foreach (var genre in mCon.Genres.ToList())
         {
             if (genre.Id == item.Id)
                 temp =  item.Movies;
         }
         return temp;
     }
 }
Example #29
0
 public bool Update(Login item)
 {
     if (item == null)
         throw new ArgumentNullException("Login is null");
     if (Get(item.Username) == null)
         return false;
     using (Context mCon = new Context())
     {
         Login temp = mCon.Login.FirstOrDefault(x => x.Username == item.Username);
         temp.Password = item.Password;
         temp.Customer = item.Customer;
         mCon.SaveChanges();
     }
     return true;
 }
Example #30
0
 public Order Add(Order item)
 {
     if (item == null)
         throw new ArgumentNullException("Order is null");
     if (item.Customer == null)
         throw new ArgumentException("Customer can not be null");
     using (Context mCon = new Context())
     {
         if (mCon.Customers.FirstOrDefault(x => x.Id == item.Customer.Id) != null)
             item.Customer = mCon.Customers.FirstOrDefault(x => x.Id == item.Customer.Id);
         item = mCon.Orders.Add(item);
         mCon.SaveChanges();
     }
     return item;
 }