Пример #1
0
        public ActionResult CreatePerformance(int id)
        {
            var model = new PerformanceVM();

            model.EventId     = id;
            ViewBag.PageTitle = "Create Performance";
            return(View("~/Views/Admin/PerformanceForm.cshtml", model));
        }
Пример #2
0
        public ActionResult AddToCart(PerformanceVM model)
        {
            var    mediator = new TicketMediator();
            CartVM cart     = mediator.GetCart();

            cart.Performances.Add(model);
            return(Redirect("/Checkout/Cart"));
        }
Пример #3
0
        public PerformanceVM GetPerformance(int id)
        {
            var performance = new PerformanceVM();

            using (var db = new ManagementToolProjectEntities())
            {
                var resp        = new PerformanceRepository(db);
                var perf        = resp.GetFirstOrDefault(p => p.PerformanceId == id);
                var transformer = new PerformanceTransformer();
                performance = transformer.Transform(perf);
            }

            return(performance);
        }
Пример #4
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));
            }
        }
Пример #5
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"));
        }
Пример #6
0
        public PerformanceVM Transform(DBModels.Performance perf)
        {
            var model = new PerformanceVM
            {
                AvailableTickets = (int)perf.TotalTickets,
                Cancelled        = perf.status,
                EventId          = (int)perf.EventId,
                PerformanceId    = perf.PerformanceId,
                PerformanceDate  = ((DateTime)perf.Date).ToString("MM/dd/yy"),
                Price            = (decimal)perf.Price,
                EventName        = perf.Event.Name,
                Location         = perf.Event.Location
            };

            return(model);
        }
Пример #7
0
        public void ThenTheSystemUpdatesTheInventory()
        {
            var performance = new PerformanceVM
            {
                AvailableTickets = 1,
                Cancelled        = false,
                EventId          = 1,
                EventName        = "TestEvent",
                LineNumber       = 0,
                Location         = null,
                PerformanceDate  = "04/23/15",
                PerformanceId    = 8,
                Price            = 0,
                Quantity         = 1
            };

            new TicketMediator().UpdatePerformance(performance);
        }
Пример #8
0
        public void GivenThatThereAreItemsInTheShoppingCart()
        {
            var performance = new PerformanceVM
            {
                AvailableTickets = 1,
                Cancelled        = false,
                EventId          = 1,
                EventName        = "TestEvent",
                LineNumber       = 0,
                Location         = null,
                PerformanceDate  = "04/23/15",
                PerformanceId    = 8,
                Price            = 0,
                Quantity         = 1
            };

            new EventController().AddToCart(performance);
        }
Пример #9
0
        public bool UpdatePerformance(PerformanceVM model)
        {
            var success = false;

            using (var db = new ManagementToolProjectEntities())
            {
                var         resp = new PerformanceRepository(db);
                Performance perf = resp.GetFirstOrDefault(p => p.PerformanceId == model.PerformanceId);

                perf.Date         = DateTime.Parse(model.PerformanceDate);
                perf.Price        = model.Price;
                perf.status       = model.Cancelled;
                perf.TotalTickets = model.AvailableTickets;
                perf.EventId      = model.EventId;

                resp.Update(perf);
                success = db.SaveChanges() > 0;
            }

            return(success);
        }
Пример #10
0
        public bool CreatePerformance(PerformanceVM model)
        {
            var success = false;

            using (var db = new ManagementToolProjectEntities())
            {
                var resp = new PerformanceRepository(db);

                var perf = new Performance
                {
                    Date         = DateTime.Parse(model.PerformanceDate),
                    EventId      = model.EventId,
                    Price        = model.Price,
                    status       = model.Cancelled,
                    TotalTickets = model.AvailableTickets
                };

                resp.Insert(perf);
                success = db.SaveChanges() > 0;
            }

            return(success);
        }
Пример #11
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));
            }
        }