Ejemplo n.º 1
0
        public ActionResult Index()
        {
            var username = ClaimsPrincipal.Current.GetUserId() ?? Request.QueryString["username"];
            var orders   = ContosoEventsApi.GetUserOrders(username);

            return(View(orders));
        }
Ejemplo n.º 2
0
        public ActionResult Index()
        {
            var   events      = ContosoEventsApi.GetEvents();
            Event ticketEvent = null;

            if (events.Any())
            {
                var randomEventNumber = new Random().Next(events.Count);
                ticketEvent = events[randomEventNumber];
            }

            return(View(ticketEvent));
        }
        public ActionResult PlaceOrder(string id, NewOrder order)
        {
            var    result  = true;
            string orderId = null;

            var eventData = ContosoEventsApi.GetEvent(id);

            if (eventData == null)
            {
                result = false;
            }
            else
            {
                var data = new OrderRequest
                {
                    OrderDate = DateTime.UtcNow,
                    UserName  = ClaimsPrincipal.Current?.GetUserId(),
                    Email     = ClaimsPrincipal.Current?.Identity?.Name,
                    EventId   = eventData.Id,
                    PaymentProcessorTokenId = string.IsNullOrWhiteSpace(order.PaymentProcessorToken) ? Guid.NewGuid().ToString(): order.PaymentProcessorToken, //We need to send a payment processor token
                    Tickets = order.TicketCount
                };
                if (string.IsNullOrWhiteSpace(data.Email))
                {
                    data.Email = order.DeliveryEmail;
                }
                if (string.IsNullOrWhiteSpace(data.UserName))
                {
                    data.UserName = order.DeliveryEmail;
                }
                if (string.IsNullOrWhiteSpace(data.FirstName))
                {
                    data.FirstName = order.FirstName;
                }
                if (string.IsNullOrWhiteSpace(data.LastName))
                {
                    data.LastName = order.LastName;
                }

                var placeUserOrderResult = ContosoEventsApi.PlaceUserOrder(data);
                result  = placeUserOrderResult.Item1;
                orderId = placeUserOrderResult.Item2;
            }

            return(View("OrderResult", new Tuple <bool, string>(result, orderId)));
        }
Ejemplo n.º 4
0
        public ActionResult RunTest(string eventId, string tag, int requestsCount)
        {
            var userName = ClaimsPrincipal.Current.GetUserId();
            var email    = ClaimsPrincipal.Current.Identity.Name;

            var simulation = new LoadSimulationRequest
            {
                BaseUrl    = ContosoEventsApi.BaseUrl,
                EventId    = eventId,
                UserName   = string.IsNullOrWhiteSpace(userName) == false ? userName : "******",
                Email      = string.IsNullOrWhiteSpace(email) == false ? email : "no_email",
                Iterations = requestsCount,
                Tag        = tag
            };

            ContosoEventsApi.RequestLoadSimulation(simulation);

            return(RedirectToAction("Index"));
        }
        public ActionResult Order(string id)
        {
            var principal = ClaimsPrincipal.Current;
            var eventData = ContosoEventsApi.GetEvent(id);

            var data = new NewOrder
            {
                Event       = eventData,
                TicketCount = 1,
                FirstName   = principal?.FindFirst(ClaimTypes.GivenName)?.Value,
                LastName    = principal?.FindFirst(ClaimTypes.Surname)?.Value,
                Address     = "1 Microsoft Way",
                City        = "Redmond",
                PostalCode  = "WA 98052",
                Country     = "US",

                DeliveryEmail = principal?.FindFirst("emails")?.Value,
                PhoneNumber   = "425 123 4567",
            };

            return(View(data));
        }
Ejemplo n.º 6
0
        public ActionResult Index()
        {
            var events = ContosoEventsApi.GetEvents();

            return(View(events));
        }
Ejemplo n.º 7
0
        public ActionResult Status()
        {
            var status = ContosoEventsApi.GetLoadSimulationStatus();

            return(View(status));
        }
        public ActionResult Details(string id)
        {
            var data = ContosoEventsApi.GetEvent(id);

            return(View(data));
        }
Ejemplo n.º 9
0
        public ActionResult Cancel(string id)
        {
            ContosoEventsApi.CancelUserOrder(id);

            return(RedirectToAction("Index"));
        }
        public ActionResult Index()
        {
            var orders = ContosoEventsApi.GetUserOrders(ClaimsPrincipal.Current.GetUserId());

            return(View(orders));
        }