Exemple #1
0
        public async Task <IActionResult> Index()
        {
            using (var client = _httpClientFactory.CreateAuthorizedClient())
            {
                var apiClient = new EventsClient(client);
                var response  = await apiClient.GetAsync();

                var list = response
                           .Result
                           .Select(x => new EventListItemViewModel
                {
                    Id          = x.Id,
                    Authors     = x.Authors,
                    Cast        = x.Cast,
                    Categories  = x.Categories.ToArray(),
                    DateTime    = x.DateTime,
                    Description = x.Description,
                    Duration    = x.Duration,
                    Title       = x.Title
                });

                var viewModel = new EventListViewModel(list);

                return(View(viewModel));
            }
        }
 public async Task DeliiverAsync()
 {
     try
     {
         using (var client = _factory.CreateAuthorizedClient())
         {
             var apiClient = new ManagementDeliveriesClient(client);
             await apiClient.DeliverAsync();
         }
     }
     catch (System.Exception e)
     {
     }
 }
 public async Task DiscardReservationsAsync()
 {
     try
     {
         using (var client = _factory.CreateAuthorizedClient())
         {
             var apiClient = new ManagementReservationsClient(client);
             await apiClient.DiscardAsync();
         }
     }
     catch (System.Exception e)
     {
     }
 }
Exemple #4
0
 public async Task FinalizeAsync()
 {
     try
     {
         using (var client = _factory.CreateAuthorizedClient())
         {
             var apiClient = new ManagementOrdersClient(client);
             await apiClient.PayAsync();
         }
     }
     catch (System.Exception e)
     {
     }
 }
 public async Task FinalizeAsync()
 {
     try
     {
         using (var client = _factory.CreateAuthorizedClient())
         {
             var api       = Environment.GetEnvironmentVariable("TICKETTRADER_API_HOST");
             var apiClient = new ManagementOrdersClient(api, client);
             await apiClient.PayAsync();
         }
     }
     catch (System.Exception e)
     {
     }
 }
Exemple #6
0
 public async Task DiscardReservationsAsync()
 {
     try
     {
         using (var client = _factory.CreateAuthorizedClient())
         {
             var api       = Environment.GetEnvironmentVariable("TICKETTRADER_API_HOST");
             var apiClient = new ManagementReservationsClient(api, client);
             await apiClient.DiscardAsync();
         }
     }
     catch (System.Exception e)
     {
     }
 }
Exemple #7
0
        public async Task <IActionResult> Index()
        {
            var eventsListCache = "eventsListCache";

            // Look for cache key.
            if (_cache.TryGetValue(eventsListCache, out EventListViewModel cachedViewModel))
            {
                return(View(cachedViewModel));
            }

            using (var client = _httpClientFactory.CreateAuthorizedClient())
            {
                var baseUrl   = Environment.GetEnvironmentVariable("TICKETTRADER_API_HOST");
                var apiClient = new EventsClient(baseUrl, client);
                var response  = await apiClient.GetAsync();

                var list = response
                           .Result
                           .Select(x => new EventListItemViewModel
                {
                    Id          = x.Id,
                    Authors     = x.Authors,
                    Cast        = x.Cast,
                    Categories  = x.Categories.ToArray(),
                    DateTime    = x.DateTime,
                    Description = x.Description,
                    Duration    = x.Duration,
                    Title       = x.Title
                });

                var viewModel = new EventListViewModel(list);


                var cacheEntryOptions = new MemoryCacheEntryOptions()
                                        .SetSlidingExpiration(TimeSpan.FromMinutes(5));

                _cache.Set(eventsListCache, viewModel, cacheEntryOptions);

                return(View(viewModel));
            }
        }