public void Delete(Adress address)
 {
     using (var ctx = new MovieShopContextDB())
     {
         var addressDB = ctx.Adresses.FirstOrDefault(item => item.Id == address.Id);
         ctx.Adresses.Remove(addressDB);
     }
 }
        public void Add(Adress address)
        {
            using (var ctx = new MovieShopContextDB())
            {
                //Create the queries
                ctx.Adresses.Add(address);

                //Execute the queries
                ctx.SaveChanges();
            }
        }
        public void Update(Adress address)
        {
            using (var ctx = new MovieShopContextDB())
            {
                var addressDB = ctx.Adresses.FirstOrDefault(item => item.Id == address.Id);
                addressDB.StreetName = address.StreetName;
                addressDB.StreetNumber = address.StreetNumber;
                addressDB.Zipcode = address.Zipcode;
                addressDB.Country = address.Country;
                ctx.SaveChanges();

            }
        }
Exemple #4
0
        public ActionResult CustomerEdit(int movieId, Customer customer, Adress address)
        {
            Movie movie = facade.GetMovieRepository().Read(movieId);
            customer.Adress = address;
            facade.GetCustomerRepository().Update(customer);
            facade.GetAddressRepository().Update(customer.Adress);

            Order order = new Order()
            {
                Date = DateTime.Now,
                CustomerId = customer.Id,
                MovieId = movieId
            };
            facade.GetOrderRepository().Add(order);

            return RedirectToAction("OrderCompletion", new { movieId = movieId});
        }
Exemple #5
0
        public ActionResult NewCustomerCreate(int movieId, Customer customer, Adress address)
        {
            CustomerViewModel viewModel = new CustomerViewModel()
            {
                Movie = facade.GetMovieRepository().Read(movieId)

            };
            customer.Adress = address;
            facade.GetCustomerRepository().Add(customer);

            Order order = new Order()
            {
                Date = DateTime.Now,
                CustomerId = customer.Id,
                MovieId = movieId
            };
            facade.GetOrderRepository().Add(order);
            return View(viewModel);
        }