public ActionResult CreatePerformance(int id) { var model = new PerformanceVM(); model.EventId = id; ViewBag.PageTitle = "Create Performance"; return(View("~/Views/Admin/PerformanceForm.cshtml", model)); }
public ActionResult AddToCart(PerformanceVM model) { var mediator = new TicketMediator(); CartVM cart = mediator.GetCart(); cart.Performances.Add(model); return(Redirect("/Checkout/Cart")); }
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); }
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)); } }
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")); }
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); }
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); }
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); }
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); }
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); }
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)); } }