public ActionResult Index(int?i, string searchTerm = null) { using (ETicketService.EventServiceClient eventClient = new ETicketService.EventServiceClient()) { eventClient.ClientCredentials.UserName.UserName = "******"; eventClient.ClientCredentials.UserName.Password = "******"; var events = eventClient.GetAllEvents().Where(e => searchTerm == null || e.Title.StartsWith(searchTerm, StringComparison.OrdinalIgnoreCase) || e.Title.Contains(searchTerm)).OrderBy(e => e.Date); return(View(events.ToList().ToPagedList(i ?? 1, 6))); } }
// GET: Event/Details/5 public ActionResult Details(int id) { using (ETicketService.EventServiceClient eventClient = new ETicketService.EventServiceClient()) { eventClient.ClientCredentials.UserName.UserName = "******"; eventClient.ClientCredentials.UserName.Password = "******"; var myEvent = eventClient.GetEvent(id); return(View(myEvent)); } }
public ActionResult Index() { using (ETicketService.EventServiceClient eventClient = new ETicketService.EventServiceClient()) { eventClient.ClientCredentials.UserName.UserName = "******"; eventClient.ClientCredentials.UserName.Password = "******"; var events = eventClient.GetAllEvents(); return(View(events)); } }
public ActionResult Create(FormCollection collection, Event myEvent) { try { using (ETicketService.EventServiceClient eventClient = new ETicketService.EventServiceClient()) { eventClient.ClientCredentials.UserName.UserName = "******"; eventClient.ClientCredentials.UserName.Password = "******"; // TODO: Add insert logic here eventClient.CreateEvent(myEvent); return(RedirectToAction("Index")); } } catch { return(View()); } }
public ActionResult Delete(int id, FormCollection collection) { try { if (ModelState.IsValid) { using (ETicketService.EventServiceClient eventClient = new ETicketService.EventServiceClient()) { eventClient.ClientCredentials.UserName.UserName = "******"; eventClient.ClientCredentials.UserName.Password = "******"; eventClient.DeleteEvent(id); } } return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Create(OrderFormViewModel orderFormViewModel) { using (ETicketService.OrderServiceClient orderClient = new ETicketService.OrderServiceClient()) { using (ETicketService.EventServiceClient eventClient = new ETicketService.EventServiceClient()) { orderClient.ClientCredentials.UserName.UserName = "******"; orderClient.ClientCredentials.UserName.Password = "******"; eventClient.ClientCredentials.UserName.UserName = "******"; eventClient.ClientCredentials.UserName.Password = "******"; string UserId = User.Identity.GetUserId(); int EventId = orderFormViewModel.EventId; int Quantity = orderFormViewModel.Quantity; Order order = new Order(); order.Quantity = Quantity; order.CustomerId = UserId; order.EventId = EventId; order.Date = DateTime.Now.Date; decimal ticketPrice = eventClient.GetEvent(EventId).TicketPrice; decimal totalPrice = ticketPrice * Quantity; order.TotalPrice = totalPrice; var myOrder = orderClient.CreateOrder(order); if (orderClient.GetOrder(myOrder) == null) { ViewBag.Message = "Order not placed, please try again!"; } else { ViewBag.Message = "Order placed :)"; } return(View()); } } }
public ActionResult Cancel(int id) { using (ETicketService.OrderServiceClient orderClient = new ETicketService.OrderServiceClient()) { using (ETicketService.EventServiceClient eventClient = new ETicketService.EventServiceClient()) { eventClient.ClientCredentials.UserName.UserName = "******"; eventClient.ClientCredentials.UserName.Password = "******"; orderClient.ClientCredentials.UserName.UserName = "******"; orderClient.ClientCredentials.UserName.Password = "******"; Order order = orderClient.GetOrder(id); string orderCustomer = order.CustomerId.ToString(); Event myEvent = eventClient.GetEvent(order.EventId); var today = DateTime.Now; var tomorrow = today.AddDays(1); if (myEvent.Date <= tomorrow) { ViewBag.Message = "You can't cancel your order, when you are one day away from the event's date or the event has already been held"; return(View()); } else { if (orderCustomer != User.Identity.GetUserId()) { ViewBag.Message = "You can't delete an order that isn't yours"; return(View()); } else { orderClient.Cancel(order); ViewBag.Message = "Canceled"; return(View()); } } } } }