public void Add(Movie movie)
 {
     using (var ctx = new MovieStoreContext())
     {
         ctx.Movies.Add(movie);
         ctx.SaveChanges();
     }
 }
        public void Add(Genre genre)
        {
            using (var ctx = new MovieStoreContext())
            {

                ctx.Genres.Add(genre);
                ctx.SaveChanges();
            }
        }
        public void Add(OrderLine orderLine)
        {
            using (var ctx = new MovieStoreContext())
            {

                ctx.OrderLines.Add(orderLine);
                ctx.SaveChanges();
            }
        }
        public void Add(Customer customer)
        {
            using (var ctx = new MovieStoreContext())
            {

                ctx.Customers.Add(customer);
                ctx.SaveChanges();
            }
        }
 public void UpdateGenre(Genre genre)
 {
     using (var ctx = new MovieStoreContext())
     {
         Genre m = ctx.Genres.Where(x => x.Id == genre.Id).First();
         m.Id = genre.Id;
         m.Name = genre.Name;
         ctx.SaveChanges();
     }
 }
        public void DeleteGenre(int id)
        {
            using (var ctx = new MovieStoreContext())
            {

                Genre m = ctx.Genres.Where(x => x.Id == id).First();
                if (m != null)
                    ctx.Genres.Remove(m);
                ctx.SaveChanges();
            }
        }
        public void DeleteCustomer(int id)
        {
            using (var ctx = new MovieStoreContext())
            {

                Customer m = ctx.Customers.Where(x => x.Id == id).First();
                if (m != null)
                    ctx.Customers.Remove(m);
                ctx.SaveChanges();
            }
        }
 public void UpdateOrderLine(OrderLine orderLine)
 {
     using (var ctx = new MovieStoreContext())
     {
         OrderLine m = ctx.OrderLines.Where(x => x.OrderId == orderLine.OrderId).First();
         m.Amount = orderLine.Amount;
         m.OrderId = orderLine.OrderId;
         m.MovieId = orderLine.MovieId;
         m.Movie = orderLine.Movie;
         m.Order = orderLine.Order;
         ctx.SaveChanges();
     }
 }
 public void UpdateCustomer(Customer customer)
 {
     using (var ctx = new MovieStoreContext())
     {
         Customer m = ctx.Customers.Where(x => x.Id == customer.Id).First();
         m.FirstName = customer.FirstName;
         m.LastName = customer.LastName;
         m.Address = customer.Address;
         m.Email = customer.Email;
         m.orders = customer.orders;
         ctx.SaveChanges();
     }
 }
Esempio n. 10
0
 public void UpdateMovie(Movie movie)
 {
     using (var ctx = new MovieStoreContext())
     {
         Movie m = ctx.Movies.Where(x => x.Id == movie.Id).First();
         m.ImageUrl = movie.ImageUrl;
         m.Title = movie.Title;
         m.Price = movie.Price;
         m.Year = movie.Year;
         m.TralierUrl = movie.TralierUrl;
         m.Genre = movie.Genre;
         m.GenreId = movie.GenreId;
         ctx.SaveChanges();
     }
 }