Example #1
0
        public async Task <JObject> GetCinemas(
            string city,
            string searchTerm,
            int distance,
            int limit,
            GetCinemasDynamicQuery dynamicQuery,
            CancellationToken cancellationToken)
        {
            if (string.IsNullOrEmpty(city?.Trim()))
            {
                throw new ArgumentNullException(nameof(city));
            }

            if (distance <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(distance),
                                                      $"{nameof(distance)} needs to be bigger than 0");
            }

            if (limit <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(limit),
                                                      $"{nameof(limit)} needs to be bigger than 0");
            }

            var query    = new GetCinemasQuery(searchTerm, city, distance, limit, dynamicQuery);
            var request  = BuildRestRequest(query.BuildRequest());
            var client   = CreateClient();
            var response = await client.ExecutePostTaskAsync <GraphQLResponse>(request, cancellationToken).ConfigureAwait(false);

            return(response?.Data?.Data);
        }
Example #2
0
        public async Task <QueryResponse <CinemaViewModel[]> > Handle(GetCinemasQuery message)
        {
            using (var conn = _connectionProvider.CreateConnection())
            {
                // TODO: Add paging, sorting and filtering
                const string sql     = @"
SELECT TOP 10 C.Id, C.Name 
FROM cine.Cinemas C
";
                var          cinemas = await conn.QueryAsync <CinemaViewModel>(sql);

                return(new QueryResponse <CinemaViewModel[]>
                {
                    Data = cinemas.ToArray()
                });
            }
        }
 public async Task <IEnumerable <Cinema> > Handle(GetCinemasQuery request, CancellationToken cancellationToken)
 {
     return(await _repository.GetAllAsync());
 }