示例#1
0
        public Reservation CreateReservation(CartModel cart, Customer customer)
        {
            var reservation  = new Reservation();
            var customerInfo = new Customer();

            customerInfo.FirstName = customer.FirstName;
            customerInfo.LastName  = customer.LastName;
            customerInfo.Email     = customer.Email;
            customerInfo.Sport     = customer.Sport;
            customerInfo.Phone     = customer.Phone;

            var slots = cart.Slots;

            reservation.ReservedSlots             = slots;
            reservation.CustomerInfo              = customer;
            reservation.PricePer                  = GetUnitPrice(reservation.TotalUnits);
            reservation.Status                    = "Submitted";
            reservation.SubmittedTimestamp        = DateTime.Now;
            reservation.PaymentCompletedTimestamp = DateTime.MaxValue;

            _appdb.AddReservation(reservation);
            _appdb.SaveChanges();

            return(reservation);
        }