public async Task <ActionResult> Index(int movieId, int cinemaFunctionId, int cinemaTheaterId)
        {
            try
            {
                var movie = await _apiClient.GetAsync <Movie>(new Uri($"{_configuration["Movies:BaseUrl"]}{movieId}"));

                var cinemaFunction = await _apiClient.GetAsync <CinemaFunction>(new Uri($"{_configuration["Booking:BaseUrl"]}{_configuration["Booking:MethodFunctionById"]}{cinemaFunctionId}"));

                var viewModel = new BookingViewModel
                {
                    AvailableSeats  = cinemaFunction.AvailableSeats,
                    PricePerTicket  = cinemaFunction.BasePrice * movie.VoteAverage / 10,
                    OriginalTitle   = movie.OriginalTitle,
                    Id              = movie.Id,
                    CinemaFuctionId = cinemaFunction.CinemaFuctionId,
                    CinemaTheaterId = cinemaTheaterId
                };
                return(View(viewModel));
            }
            catch (Exception)
            {
                return(View("Error", new ErrorViewModel {
                    RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier
                }));
            }
        }
Beispiel #2
0
        public async Task <IEnumerable <Movie> > GetMovies()
        {
            var movies = await _apiClient.GetAsync <IEnumerable <Movie> >(new Uri(string.Format(_movieSettings.BaseUrl, _movieSettings.ServiceApiKey)), _movieSettings.TokenName);

            movies.ToList().ForEach(x => x.FullPosterPath = string.Format(_movieSettings.BaseUrlImage, x.PosterPath));
            return(movies);
        }
Beispiel #3
0
        // GET: UserBooking
        public async Task <ActionResult> Index()
        {
            IEnumerable <CinemaReservation> bookings = default;

            try
            {
                bookings = await _apiClient.GetAsync <IEnumerable <CinemaReservation> >
                               (new Uri($"{_configuration["Booking:BaseUrl"]}{_configuration["Booking:MethodBooking"]}{User.FindFirst(x => x.Type == "sub").Value}"));

                return(View(bookings));
            }
            catch (Exception)
            {
                return(View("Error", new ErrorViewModel {
                    RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier
                }));
            }
        }
Beispiel #4
0
        public async Task <IActionResult> Get()
        {
            string result;


            try
            {
                result = await _outraAPIClient.GetAsync();
            }
            catch (Exception e)
            {
                throw;
            }


            // var client = _httpClientFactory.CreateClient(NamedHttpClients.OutraAPIClient);
            //var result = await client.GetStringAsync("/");
            // var models = _personService.GetAll();

            return(Ok(result));
        }
        public async Task <IEnumerable <Article> > GetNewsAsync(int articleCount)
        {
            if (articleCount < 1)
            {
                throw new ArgumentException("The article number to retrieve must be more than 1");
            }

            var articleIds = await client.GetAsync <int[]>("https://hacker-news.firebaseio.com/v0/topstories.json?print=pretty");

            articleCount = articleCount < articleIds.Length ? articleCount : articleIds.Length;

            var articles = await RetrieveArticles(articleCount, articleIds);

            return(_mapper.Map <IEnumerable <Item>, IEnumerable <Article> >(articles));
        }
Beispiel #6
0
        public async Task <ActionResult> Index()
        {
            var viewModel = new MoviesViewModel();

            try
            {
                var movies = await _apiClient.GetAsync <IEnumerable <Movie> >(new Uri(_configuration["Movies:BaseUrl"]));

                viewModel.Movies = movies;
                return(View(viewModel));
            }
            catch (Exception)
            {
                return(View("Error", new ErrorViewModel {
                    RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier
                }));
            }
        }
Beispiel #7
0
        public AMPS_Config_UsersViewModel UserByUserName(string userName)
        {
            string apiUrl = _apiSettings.ApaliseInvoiceAPI.HostedURL + ApaliseInvoiceAPIEndPoint.User + "/UserByUserName/" + userName;

            return(_apiClient.GetAsync <AMPS_Config_UsersViewModel>(apiUrl).Result);
        }
Beispiel #8
0
        public static async Task <CustomerModel> GetCustomerAsync(int customerId)
        {
            var model = await sampleAPIClient.GetAsync <CustomerModel>($"{getCustomerEndPoint}{customerId}");

            return(model);
        }
Beispiel #9
0
        public IList <AMPS_Config_CompanyViewModel> companies()
        {
            string apiUrl = _apiSettings.ApaliseInvoiceAPI.HostedURL + ApaliseInvoiceAPIEndPoint.Company;

            return(_apiClient.GetAsync <IList <AMPS_Config_CompanyViewModel> >(apiUrl).Result);
        }