Ejemplo n.º 1
0
        public ActionResult BuyTickets(BuyTicketsVM model)
        {
            var mediator = new TicketMediator();

            model.Performances = new List <PerformanceVM>();
            var perfs    = mediator.GetAllPerformances();
            var fromDate = DateTime.Parse(model.FromDate);
            var toDate   = fromDate.AddYears(1);

            if (!string.IsNullOrEmpty(model.ToDate))
            {
                toDate = DateTime.Parse(model.ToDate).AddHours(1);
            }

            perfs = perfs.Where(p => DateTime.Parse(p.PerformanceDate) > fromDate && DateTime.Parse(p.PerformanceDate) < toDate).ToList();

            var selectedEventType    = model.Events.Where(p => p.SelectedIndicator).Select(e => e.EventId);
            var selectedCategoryType = model.Categories.Where(p => p.SelectedIndicator).Select(e => e.CategoryId);

            if (selectedEventType.Count() > 0)
            {
                perfs = perfs.Where(p => selectedEventType.Contains(p.EventId)).ToList();
            }

            if (selectedCategoryType.Count() > 0 && (perfs != null && perfs.Count > 0))
            {
                perfs = perfs.Where(p => selectedCategoryType.Contains(p.EventId)).ToList();
            }


            model.Performances = perfs;
            return(View(model));
        }
Ejemplo n.º 2
0
        public ActionResult EventList()
        {
            var mediator = new TicketMediator();
            var model    = mediator.GetEvents();

            return(View("~/Views/Admin/EventList.cshtml", model));
        }
Ejemplo n.º 3
0
        private void checkTicketBtn_Click(object sender, RoutedEventArgs e)
        {
            string ticketIDStr = ticketIDTxt.Text.Trim();
            int    ticketID;
            bool   success = int.TryParse(ticketIDStr, out ticketID);

            if (!success)
            {
                errorLbl.Text = "Ticket ID must be a number";
            }
            else
            {
                TicketMediator mediator = new TicketMediator();
                Ticket         ticket   = mediator.getTicket(ticketID);
                if (ticket == null)
                {
                    MessageBox.Show("Ticket doesn't exist");
                }
                else
                {
                    if (((DateTime)ticket.dateCreated).Date == DateTime.Now.Date)
                    {
                        MessageBox.Show("Ticket is valid!");
                    }
                    else
                    {
                        MessageBox.Show("Ticket is invalid!");
                    }
                }
            }
        }
Ejemplo n.º 4
0
        //[HttpPost]
        //public ActionResult BuyTickets(string FromDate, string ToDate)
        //{
        //    var mediator = new TicketMediator();
        //    var model = new BuyTicketsVM();
        //    model.Performances = new List<PerformanceVM>();
        //    model.Performances = mediator.GetAllPerformances();

        //    model.Categories = new List<Category>();
        //    model.Categories = mediator.GetEventTypes();
        //    model.Events = new List<EventItem>();
        //    model.Events = mediator.GetEventItems();
        //    model.FromDate = DateTime.Today.ToString("MM/dd/yyyy");
        //    return View(model);
        //}

        public ActionResult EventList()
        {
            var            mediator = new TicketMediator();
            List <EventVM> events   = mediator.GetActiveEvents();

            return(View(events));
        }
Ejemplo n.º 5
0
        public ActionResult Index()
        {
            var mediator = new TicketMediator();
            var model    = mediator.GetUpcomingPerformances();

            return(View("~/Views/Home/Index.cshtml", model));
        }
Ejemplo n.º 6
0
            public void ReturnTrueIfNotEligible()
            {
                _PersonModel.Age        = 6;
                _TicketModel.MinimumAge = 21;
                TicketMediator TicketMediator = new TicketMediator(_PersonModel, _TicketModel);

                Assert.IsFalse(TicketMediator.IsEligibleToAttend());
            }
Ejemplo n.º 7
0
        public ActionResult AddToCart(PerformanceVM model)
        {
            var    mediator = new TicketMediator();
            CartVM cart     = mediator.GetCart();

            cart.Performances.Add(model);
            return(Redirect("/Checkout/Cart"));
        }
Ejemplo n.º 8
0
            public void ReturnTrueIfEligibleAndIsSeniorAdmission()
            {
                _PersonModel.Age = 65;
                TicketMediator TicketMediator = new TicketMediator(_PersonModel, _TicketModel);

                Assert.IsTrue(TicketMediator.IsEligibleToAttend());
                Assert.IsTrue(TicketMediator.GetTicketPrice() == _TicketModel.SeniorAdmission);
            }
Ejemplo n.º 9
0
        public ActionResult EditPerformance(int id)
        {
            var mediator = new TicketMediator();
            var model    = mediator.GetPerformance(id);

            ViewBag.PageTitle = "Edit Performance";
            return(View("~/Views/Admin/PerformanceForm.cshtml", model));
        }
Ejemplo n.º 10
0
        public ActionResult EventDetails(int id)
        {
            var mediator = new TicketMediator();
            var model    = mediator.GetEvent(id);

            //model.Performances = new List<PerformanceVM>();
            //model.Performances = mediator.GetPerformances(id);
            return(View(model));
        }
Ejemplo n.º 11
0
            public void ReturnTrueIfEligibleAndIsChildAdmission()
            {
                _TicketModel.MinimumAge = 0;
                _PersonModel.Age        = 6;

                TicketMediator TicketMediator = new TicketMediator(_PersonModel, _TicketModel);

                Assert.IsTrue(TicketMediator.IsEligibleToAttend());
                Assert.IsTrue(TicketMediator.GetTicketPrice() == _TicketModel.ChildAdmission);
            }
Ejemplo n.º 12
0
        public ActionResult EditEvent(int id)
        {
            var mediator = new TicketMediator();
            var model    = mediator.GetEvent(id);

            model.Categories = mediator.GetEventTypes();

            ViewBag.PageTitle = "Edit Event";
            return(View("~/Views/Admin/EventForm.cshtml", model));
        }
Ejemplo n.º 13
0
        public ActionResult PerformanceList(int id)
        {
            var mediator = new TicketMediator();
            var model    = mediator.GetEvent(id);

            model.Performances = new List <PerformanceVM>();
            model.Performances = mediator.GetPerformances(id).OrderBy(d => d.PerformanceDate).ToList();

            return(View("~/Views/Admin/PerformanceList.cshtml", model));
        }
Ejemplo n.º 14
0
        public Ticket generateTicket()
        {
            TicketMediator mediator = new TicketMediator();

            Ticket ticket = new Ticket();

            ticket.ticketID    = mediator.getLastID() + 1;
            ticket.dateCreated = DateTime.Now;

            return(ticket);
        }
Ejemplo n.º 15
0
        private void inputPaymentBtn_Click(object sender, RoutedEventArgs e)
        {
            string paymentStr = paymentTxt.Text.Trim();
            int    payment;

            bool success = int.TryParse(paymentStr, out payment);

            if (!success)
            {
                errorLbl.Text = "Payment must be a number!";
            }
            else
            {
                int change = totalPrice - payment;
                if (change > 0)
                {
                    errorLbl.Text = "Payment is not enough!";
                }
                else
                {
                    TicketMediator mediator = new TicketMediator();
                    TicketFactory  factory  = new TicketFactory();

                    changeLbl.Text = "Change = \t\tRp. " + Math.Abs(change).ToString();

                    ticketList = new List <Ticket>();

                    for (int i = 0; i < quantity; i++)
                    {
                        ticketList.Add(mediator.addTicket(factory.generateTicket()));
                    }

                    TicketTransactionMediator tmediator = new TicketTransactionMediator();
                    TicketTransactionFactory  tfactory  = new TicketTransactionFactory();

                    foreach (Ticket ticket in ticketList)
                    {
                        TicketTransaction transaction = tmediator.addTicketTransaction(tfactory.createNewTicketTransaction(ticket.ticketID));
                        if (transaction == null)
                        {
                            MessageBox.Show("Buy ticket failed!");
                            return;
                        }
                    }

                    MessageBox.Show("Buy ticket success!");
                    nextBarcodeBtn.Visibility = Visibility.Visible;
                    qr = new QRCode(ticketList.ElementAt(counter));
                    qr.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
                    qr.Show();
                }
            }
        }
Ejemplo n.º 16
0
        public ActionResult CreateEvent()
        {
            var model = new EventVM();

            ViewBag.PageTitle = "Create Event";

            var mediator = new TicketMediator();

            model.Categories = mediator.GetEventTypes();
            model.Active     = true;
            return(View("~/Views/Admin/EventForm.cshtml", model));
        }
Ejemplo n.º 17
0
        public ActionResult Review()
        {
            var    mediator = new TicketMediator();
            CartVM cart     = mediator.GetCart();

            if (cart.Performances == null || cart.Performances.Count == 0)
            {
                return(Redirect("/checkout/cart"));
            }
            var model = new PaymentVM();

            model.SameAsBilling = true;
            return(View("~/Views/Checkout/Review.cshtml", model));
        }
Ejemplo n.º 18
0
        public ActionResult BuyTickets()
        {
            var mediator = new TicketMediator();
            var model    = new BuyTicketsVM();

            model.Performances = new List <PerformanceVM>();
            model.Performances = mediator.GetAllPerformances();

            model.Categories = new List <Category>();
            model.Categories = mediator.GetEventTypes();
            model.Events     = new List <EventItem>();
            model.Events     = mediator.GetEventItems();
            model.FromDate   = DateTime.Today.ToString("MM/dd/yyyy");
            return(View(model));
        }
Ejemplo n.º 19
0
        public ActionResult CreateEvent(EventVM model)
        {
            var mediator = new TicketMediator();
            var success  = mediator.CreateEvent(model);

            if (success)
            {
                return(Redirect("/admin/eventlist"));
            }
            else
            {
                ViewBag.PageTitle = "Create Event";
                ModelState.AddModelError("ErrorMessage", "Unable to create event. Please verify input.");
                return(View("~/Views/Admin/EventForm.cshtml", model));
            }
        }
Ejemplo n.º 20
0
        public ActionResult Confirmation()
        {
            var    mediator = new TicketMediator();
            CartVM cart     = mediator.GetCart();

            mediator.ClearCart();

            decimal total = 0;

            foreach (var perf in cart.Performances)
            {
                total += (perf.Quantity * perf.Price);
            }
            cart.Total = total;
            return(View(cart));
        }
Ejemplo n.º 21
0
        public ActionResult EditPerformance(PerformanceVM model)
        {
            var mediator = new TicketMediator();
            var success  = mediator.UpdatePerformance(model);

            if (success)
            {
                return(Redirect("/admin/performanceList/" + model.EventId));
            }
            else
            {
                ViewBag.PageTitle = "Edit Performance";
                ModelState.AddModelError("ErrorMessage", "Unable to create event. Please verify input.");
                return(View("~/Views/Admin/PerformanceForm.cshtml", model));
            }
        }
Ejemplo n.º 22
0
        public ActionResult Remove(PerformanceVM perf)
        {
            var mediator = new TicketMediator();
            var cart     = mediator.GetCart();

            cart.Performances.RemoveAt(perf.LineNumber);

            int i = 0;

            foreach (var performance in cart.Performances)
            {
                perf.LineNumber = i;
                i++;
            }
            return(Redirect("/checkout/cart"));
        }
Ejemplo n.º 23
0
        public ActionResult Cart()
        {
            var     mediator = new TicketMediator();
            CartVM  model    = mediator.GetCart();
            int     i        = 0;
            decimal total    = 0;

            foreach (var perf in model.Performances)
            {
                perf.LineNumber = i;
                i++;
                total += (perf.Quantity * perf.Price);
            }
            model.Total = total;

            return(View(model));
        }
Ejemplo n.º 24
0
        public ActionResult Review(PaymentVM model)
        {
            var oMediator = new OrderMediator();
            var tMediator = new TicketMediator();

            if (model.SameAsBilling)
            {
                model.ShippingAddress.Address1 = model.BillingAddress.Address1;
                model.ShippingAddress.City     = model.BillingAddress.City;
                model.ShippingAddress.State    = model.BillingAddress.State;
                model.ShippingAddress.Zip      = model.BillingAddress.Zip;
            }
            var success = oMediator.CreateOrder(model);

            if (success)
            {
                //tMediator.ClearCart();
                return(Redirect("/checkout/confirmation"));
            }

            return(View("~/Views/Checkout/Review.cshtml", model));
        }
Ejemplo n.º 25
0
        public ActionResult CreatePerformance(PerformanceVM model)
        {
            if (string.IsNullOrEmpty(model.PerformanceDate))
            {
                model.PerformanceDate = "";
                ViewBag.PageTitle     = "Create Performance";
                return(View("~/Views/Admin/PerformanceForm.cshtml", model));
            }
            var mediator = new TicketMediator();

            model.PerformanceId = 0;
            var success = mediator.CreatePerformance(model);

            if (success)
            {
                return(Redirect("/admin/performanceList/" + model.EventId));
            }
            else
            {
                ViewBag.PageTitle = "Create Performance";
                ModelState.AddModelError("ErrorMessage", "Unable to create performance. Please verify input.");
                return(View("~/Views/Admin/PerformanceForm.cshtml", model));
            }
        }