Exemple #1
0
        public int AvailableAllocation()
        {
            int salesAndReservaations = 0;

            TicketPurchases.ForEach(t => salesAndReservaations += t.TicketQuantity);
            TicketReservations.FindAll(r => r.StillActive()).ForEach(t => salesAndReservaations += t.TicketQuantity);

            return(Allocation - salesAndReservaations);
        }
Exemple #2
0
        public TicketPurchase PurchaseTicketWith(Guid reservationId)
        {
            if (!CanPurchaseTicketWith(reservationId))
            {
                throw new ApplicationException("此预定票不能被购买");
            }
            TicketReservation ticketReservation = GetTicketReservationWith(reservationId);
            TicketPurchase    ticketPurchase    = TicketPurchaseFactory.CreateTicket(this, ticketReservation.TicketQuantity);

            ticketReservation.HasBeenRedeemed = true;
            TicketPurchases.Add(ticketPurchase);

            return(ticketPurchase);
        }
        public int Add(TicketPurchaseModel ticketPurchaseModel, string connectionString, int tenantId)
        {
            using (var context = CreateContext(connectionString, tenantId))
            {
                //password not required to save demo friction
                var ticketPurchase = new TicketPurchases
                {
                    CustomerId    = ticketPurchaseModel.CustomerId,
                    PurchaseDate  = DateTime.Now,
                    PurchaseTotal = ticketPurchaseModel.PurchaseTotal
                };

                context.TicketPurchases.Add(ticketPurchase);
                context.SaveChanges();

                return(ticketPurchase.TicketPurchaseId);
            }
        }