예제 #1
0
파일: Booking.cs 프로젝트: s-leonard/Tarts
 public Booking(Customer customer, Ticket ticket, int quantity)
 {
     Created = DateTime.Now;
     Status = BookingStatus.Reservation;
     Quantity = (quantity > 0) ? quantity : 1;
     Customer = customer;
     Ticket = ticket;
     TicketPrice = Ticket.Price;
     Event = Ticket.Event;
     Reference = GenerateUniqueReference();
     BookingFee = ticket.BookingFee;
     Payments = new List<Payment>();
 }
예제 #2
0
 public CreateCustomerViewModel(Ticket ticket = null, CreateCustomerPostModel postModel = null)
 {
     if (ticket != null)
     {
         EventName = ticket.Event.Name;
         EventSlug = ticket.Event.Slug;
         TicketID = ticket.ID;
         TicketName = ticket.Name;
     }
     if(postModel != null)
     {
         FirstName = postModel.FirstName;
         Surname = postModel.Surname;
         Email = postModel.Email;
     }
 }
예제 #3
0
        public ActionResult CustomerAccount(string eventName, int ticketID)
        {
            Ticket = Repo.GetById<Ticket>(ticketID);
            if((Ticket == null) || (Ticket.Remaining < 1))
                return RedirectToAction("SoldOut");

            GetCustomerViaFacebook();
            if (ViewBag.Customer != null)
            {
                var booking = new Booking(ViewBag.Customer, Ticket, 1);
                Repo.Save(booking);
                return RedirectToAction("ReservationSummary", new { id = booking.ID });
            }

            return View(new CreateCustomerViewModel(Ticket));
        }
예제 #4
0
 public ActionResult AccountLogin(CustomerLoginPostModel model)
 {
     Ticket = Repo.GetById<Ticket>(model.ticketID);
     if ((Ticket == null) || (Ticket.Remaining < 1))
         return RedirectToAction("SoldOut");
     var existing = Repo.GetByFieldName<Customer>("Email", model.Email);
     if (existing != null)
     {
         if (existing.Password.Decrypt() == model.Password)
         {
             AddCustomerLoginCookie(existing);
             var booking = new Booking(existing, Ticket, 1);
             Repo.Save(booking);
             return RedirectToAction("ReservationSummary", new { id = booking.ID });
         }
         ViewBag.ErrorMessage = "Login Failed";
     }
     else
         ViewBag.ErrorMessage = "No customer account was found for that email address";
     return View(new CreateCustomerViewModel(Ticket));
 }
예제 #5
0
파일: Event.cs 프로젝트: s-leonard/Tarts
 public virtual ReturnValue UpdateTicketInfo(Ticket ticket, string name, decimal price, decimal bookingFee, int allocation, bool enabled)
 {
     var retVal = ticket.UpdateTicketInfo(name, price, bookingFee, allocation, enabled);
     ReCalculateTicketTotals();
     return retVal;
 }
예제 #6
0
파일: Event.cs 프로젝트: s-leonard/Tarts
 public virtual void RemoveTicket(Ticket ticket)
 {
     if (Tickets.Contains(ticket))
     {
         if (ticket.Sold == 0)
             Tickets.Remove(ticket);
         else
             ticket.Disable();
     }
 }
예제 #7
0
파일: Event.cs 프로젝트: s-leonard/Tarts
 public virtual void EnableTicket(Ticket ticket)
 {
     ticket.Enable();
     ReCalculateTicketTotals();
 }
예제 #8
0
파일: Event.cs 프로젝트: s-leonard/Tarts
 public virtual Ticket AddTicket(string name, decimal price)
 {
     var ticket =new Ticket() {Name=name, Price=price};
     if (!Tickets.Contains(ticket))
         Tickets.Add(ticket);
     ReCalculateTicketTotals();
     return ticket;
 }
예제 #9
0
        public ActionResult CustomerAccount(CreateCustomerPostModel model)
        {
            Ticket = Repo.GetById<Ticket>(model.ticketID);
            if ((Ticket == null) || (Ticket.Remaining < 1)) return RedirectToAction("SoldOut");

            var existing = Repo.GetByFieldName<Customer>("Email", model.Email);
            if (existing != null)
            {
                ViewBag.ErrorMessage = "A user already exists with that email address";
                return View(new CreateCustomerViewModel(Ticket,model));
            }

            var cust = new Customer(model.Email, model.FirstName, model.Surname, model.Password);
            var valid = cust.Validate();
            if(!valid.Succeeded)
            {
                ViewBag.ErrorMessage =  valid.Message;
                return View(new CreateCustomerViewModel(Ticket, model));
            }
            Repo.Save(cust);
            var booking = new Booking(cust, Ticket, 1);
            Repo.Save(booking);
            return RedirectToAction("ReservationSummary", new {id=booking.ID});
        }