Ejemplo n.º 1
0
        public IActionResult SelectDiscount(string armChairId, string showId, string discountByShowId)
        {
            if (string.IsNullOrEmpty(armChairId) || string.IsNullOrEmpty(showId) || string.IsNullOrEmpty(discountByShowId))
            {
                return(NotFound());
            }
            var cart = new Cart
            {
                ArmChairId        = armChairId,
                CartId            = Guid.NewGuid().ToString(),
                User              = UserManager.FindByNameAsync(User.Identity.Name).Result,
                DiscountsByShowId = discountByShowId,
                DateTime          = DateTime.Now
            };
            var armChairByRoom = CartRepository.GetArmChairByRoomById(armChairId, showId);

            armChairByRoom.StateArmChair = StateArmChair.sold;
            CartRepository.UpdateArmChairByRoom(armChairByRoom);
            CartRepository.AddCart(cart);
            var discounstByShow   = CartRepository.GetDiscountByShowById(discountByShowId);
            var userBouthArmChair = new UserBoughtArmChair
            {
                ShowId = discounstByShow.ShowId,
                Show   = discounstByShow.Show,
                UserBoughtArmChairId = Guid.NewGuid().ToString(),
                UserId           = UserManager.FindByNameAsync(User.Identity.Name).Result.Id,
                ArmChairByRoomId = CartRepository.GetArmChairByRoomById(armChairId, showId).ArmChairByRoomId
            };

            CartRepository.AddUserBoughtArmChair(userBouthArmChair);
            return(RedirectToAction("SelectArmChair", new Dictionary <string, string> {
                { "id", discounstByShow.ShowId }
            }));
        }
Ejemplo n.º 2
0
 public void AddUserBoughtArmChair(UserBoughtArmChair userBoughtArmChair)
 {
 }
Ejemplo n.º 3
0
 public void AddUserBoughtArmChair(UserBoughtArmChair userBoughtArmChair)
 {
     _context.UserBoughtArmChair.Add(userBoughtArmChair);
     _context.SaveChanges();
 }
Ejemplo n.º 4
0
        public List <Pay> GetPayByUserIdAndPayCartId(string userId, string payCartId)
        {
            string newPayCartId         = Guid.NewGuid().ToString();
            string PayId                = Guid.NewGuid().ToString();
            string discoutID            = Guid.NewGuid().ToString();
            string movieID              = Guid.NewGuid().ToString();
            string movieTypeID          = Guid.NewGuid().ToString();
            string room1ID              = Guid.NewGuid().ToString();
            string room2ID              = Guid.NewGuid().ToString();
            string showID               = Guid.NewGuid().ToString();
            string armChairID           = Guid.NewGuid().ToString();
            string armChairByRoomID     = Guid.NewGuid().ToString();
            string userBoughtArmChairID = Guid.NewGuid().ToString();

            User user = new User
            {
                Role     = Roles.Client,
                Name     = "Valid",
                LastName = ":)"
            };


            PayCart payCart = new PayCart()
            {
                User        = user,
                CardHash    = "zwxXyz",
                DateTime    = DateTime.Now,
                PayCartId   = newPayCartId,
                PayedMoney  = 1,
                PayedPoints = 1,
                UserId      = Guid.NewGuid().ToString()
            };

            MovieType movieType1 = new MovieType()
            {
                MovieTypeId = Guid.NewGuid().ToString(),
                Name        = "Crime"
            };

            Movie movie = new Movie()
            {
                MovieId     = movieID,
                DateUpload  = DateTime.Now,
                Name        = "The Godfather",
                Description = "An organized crime dynasty's aging patriarch transfers control of his clandestine empire to his reluctant son.",
                Director    = "Francis Ford Coppola",
                URL         = "https://localhost:44304/img/movie.jpg",
                MovieType   = movieType1,
                MovieTypeId = movieTypeID
            };

            Room room1 = new Room()
            {
                RoomId      = room1ID,
                Name        = "2B",
                NoArmChairs = 1
            };

            Room room2 = new Room()
            {
                RoomId      = room2ID,
                Name        = "A1",
                NoArmChairs = 2
            };

            Show show = new Show()
            {
                ShowId        = showID,
                DateTime      = DateTime.Now,
                Movie         = movie,
                MovieId       = movieID,
                Price         = 1,
                PriceInPoints = 1,
                Room          = room1,
                RoomId        = room1ID
            };

            ArmChair armChair = new ArmChair()
            {
                ArmChairId = armChairID,
                No         = 2
            };

            ArmChairByRoom armChairByRoom = new ArmChairByRoom()
            {
                ArmChairByRoomId = armChairByRoomID,
                ArmChairId       = armChairID,
                ArmChair         = armChair,
                RoomId           = room2ID,
                Room             = room2,
                StateArmChair    = StateArmChair.ready,
                Show             = show,
                ShowId           = show.ShowId
            };

            UserBoughtArmChair userBoughtArmChair = new UserBoughtArmChair()
            {
                UserBoughtArmChairId = userBoughtArmChairID,
                ArmChairByRoomId     = armChairByRoomID,
                ArmChairByRoom       = armChairByRoom,
                ShowId = showID,
                Show   = show,
                UserId = userId,
                User   = user
            };

            Discount discount1 = new Discount()
            {
                DiscountId = discoutID,
                Name       = "Black Friday",
                Percent    = 15
            };



            Pay pay = new Pay()
            {
                PayId                = PayId,
                PayCartId            = newPayCartId,
                DiscountId           = discoutID,
                Discount             = discount1,
                PayCart              = payCart,
                UserBougthArmChairId = userBoughtArmChairID,
                UserBoughtArmChair   = userBoughtArmChair
            };


            List <Pay> pays = new List <Pay>();

            pays.Add(pay);

            return(pays);
        }