コード例 #1
0
        public async Task should_get_event_details()
        {
            var request = new EventListRequest();

            request.Lang = "ru";

            var fieldBuilder = new FieldsBuilder();

            request.Fields      = fieldBuilder.WithField(EventListRequest.FieldNames.ID).Build();
            request.ActualSince = DateTime.Today;
            request.Location    = Location.Spb;

            //then
            var res = await request.ExecuteAsync();

            var first = res.Results.First();

            var detailsRequest = new EventDetailsRequest();

            detailsRequest.EventId = first.Id;
            var actual = await detailsRequest.ExecuteAsync();

            Assert.IsNotNull(actual);
            Assert.AreEqual(actual.Id, first.Id);
        }
コード例 #2
0
        private async void OnLoaded(object sender, RoutedEventArgs e)
        {
            await LoadEventOfTheDay();

            var request = new EventListRequest();

            request.Lang   = "ru";
            request.Expand = string.Format("{0},{1}", EventListRequest.ExpandNames.IMAGES, EventListRequest.ExpandNames.PLACE);

            var fieldBuilder = new FieldsBuilder();

            request.Fields = fieldBuilder
                             .WithField(EventListRequest.FieldNames.BODY_TEXT)
                             .WithField(EventListRequest.FieldNames.COMMENTS_COUNT)
                             .WithField(EventListRequest.FieldNames.DESCRIPTION)
                             .WithField(EventListRequest.FieldNames.ID)
                             .WithField(EventListRequest.FieldNames.IMAGES)
                             .WithField(EventListRequest.FieldNames.PLACE)
                             .WithField(EventListRequest.FieldNames.PUBLICATION_DATE)
                             .WithField(EventListRequest.FieldNames.PRICE)
                             .WithField(EventListRequest.FieldNames.TITLE)
                             .WithField(EventListRequest.FieldNames.SITE_URL)
                             .WithField(EventListRequest.FieldNames.SLUG).Build();
            request.ActualSince = DateTime.Today;
            request.Location    = Location.Spb;

            var res = await request.ExecuteAsync();

            foreach (var result in res.Results)
            {
                Items.Add(new EventViewModel(result.Images.First().Thumbnail.Small, result.Title, result.Place));
            }
        }
コード例 #3
0
        public async Task should_get_events_with_fields_2()
        {
            var request = new EventListRequest();

            request.Lang   = "ru";
            request.Expand = string.Format("{0},{1},{2},{3},{4}",
                                           EventListRequest.ExpandNames.IMAGES,
                                           EventListRequest.ExpandNames.PLACE,
                                           EventListRequest.ExpandNames.LOCATION,
                                           EventListRequest.ExpandNames.DATES,
                                           EventListRequest.ExpandNames.PARTICIPANTS);

            var fieldBuilder = new FieldsBuilder();

            request.Fields = fieldBuilder
                             .WithField(EventListRequest.FieldNames.BODY_TEXT)
                             .WithField(EventListRequest.FieldNames.COMMENTS_COUNT)
                             .WithField(EventListRequest.FieldNames.CATEGORIES)
                             .WithField(EventListRequest.FieldNames.DESCRIPTION)
                             .WithField(EventListRequest.FieldNames.DATES)
                             .WithField(EventListRequest.FieldNames.FAVORITES_COUNT)
                             .WithField(EventListRequest.FieldNames.AGE_RESTRICTION)
                             .WithField(EventListRequest.FieldNames.ID)
                             .WithField(EventListRequest.FieldNames.IMAGES)
                             .WithField(EventListRequest.FieldNames.IS_FREE)
                             .WithField(EventListRequest.FieldNames.BODY_TEXT)
                             .WithField(EventListRequest.FieldNames.LOCATION)
                             .WithField(EventListRequest.FieldNames.PARTICIPANTS)
                             .WithField(EventListRequest.FieldNames.PLACE)
                             .WithField(EventListRequest.FieldNames.PUBLICATION_DATE)
                             .WithField(EventListRequest.FieldNames.PRICE)
                             .WithField(EventListRequest.FieldNames.SHORT_TITLE)
                             .WithField(EventListRequest.FieldNames.SITE_URL)
                             .WithField(EventListRequest.FieldNames.SLUG).Build();
            request.ActualSince = DateTime.Today;
            request.Location    = Location.Spb;

            var res = await request.ExecuteAsync();

            Assert.IsNotNull(res);
            Assert.IsTrue(res.Count > 0);
            Assert.IsNotNull(res.Next);
            Assert.IsTrue(res.Results.Any());

            var first = res.Results.First();

            Assert.IsNotNull(first.BodyText);
            Assert.IsNotNull(first.CommentsCount);
        }
コード例 #4
0
        public async Task should_get_events_with_fields()
        {
            var request = new EventListRequest();

            request.Lang   = "ru";
            request.Fields = "age_restriction,is_free";

            var res = await request.ExecuteAsync();

            Assert.IsNotNull(res);
            Assert.IsTrue(res.Count > 0);
            Assert.IsNotNull(res.Next);
            Assert.IsTrue(res.Results.Any());

            var first = res.Results.First();

            Assert.IsNotNull(first.AgeRestriction);
            Assert.IsNotNull(first.IsFree);
        }
コード例 #5
0
        public async Task should_get_something()
        {
            var request = new EventListRequest();

            request.Lang = "ru";

            var res = await request.ExecuteAsync();

            Assert.IsNotNull(res);
            Assert.IsTrue(res.Count > 0);
            Assert.IsNotNull(res.Next);
            Assert.IsTrue(res.Results.Any());

            var first = res.Results.First();

            Assert.IsNotNull(first.Id);
            Assert.IsNotNull(first.Title);
            Assert.IsNotNull(first.Slug);
        }
コード例 #6
0
        public async Task should_get_event_kids()
        {
            var request = new EventListRequest();

            request.Lang       = "ru";
            request.Categories = "kids";
            request.Location   = Location.Spb;

            //then
            var res = await request.ExecuteAsync();

            var first = res.Results.First();

            var detailsRequest = new EventCommentsRequest();

            detailsRequest.EventId = first.Id;
            var actual = await detailsRequest.ExecuteAsync();

            Assert.IsNotNull(actual);
        }
コード例 #7
0
        public async Task <IEventListResponse> GetEvents(string next, FilterDefinition filterDefinition)
        {
            if (filterDefinition == null)
            {
                throw new ArgumentNullException(nameof(filterDefinition));
            }

            var request = new EventListRequest();

            request.Lang        = _culture;
            request.TextFormat  = TextFormatEnum.Plain;
            request.Next        = next;
            request.IsFree      = filterDefinition.IsFree;
            request.Categories  = filterDefinition.Categories;
            request.ActualSince = filterDefinition.ActualSince;
            request.ActualUntil = filterDefinition.ActualUntil;
            request.Expand      = string.Format("{0},{1}", EventListRequest.ExpandNames.IMAGES, EventListRequest.ExpandNames.PLACE);

            var fieldBuilder = new FieldsBuilder();

            request.Fields = fieldBuilder
                             .WithField(EventListRequest.FieldNames.DESCRIPTION)
                             .WithField(EventListRequest.FieldNames.ID)
                             .WithField(EventListRequest.FieldNames.IMAGES)
                             .WithField(EventListRequest.FieldNames.PLACE)
                             .WithField(EventListRequest.FieldNames.IS_FREE)
                             .WithField(EventListRequest.FieldNames.PRICE)
                             .WithField(EventListRequest.FieldNames.TITLE)
                             .WithField(EventListRequest.FieldNames.DATES)
                             .WithField(EventListRequest.FieldNames.CATEGORIES)
                             .WithField(EventListRequest.FieldNames.AGE_RESTRICTION).Build();
            request.ActualSince = DateTime.Today;
            request.Location    = _location;

            var res = await request.ExecuteAsync();

            return(res);
        }