コード例 #1
0
        public async Task TestCreateGetEvent()
        {
            var start = DateTime.Now;
            var end   = new DateTime(2015, 1, 25);
            var close = start.AddDays((end - start).TotalDays / 2);

            var response1 = await _accountingService.CreateAccount(new CreateAccountRequest { Email = this.UniqueEmail });

            var response2 = await _accountingService.CreateAccount(new CreateAccountRequest { Email = this.UniqueEmail });

            CreateEventResponse response = await _eventsService.CreateEvent(new CreateEventRequest
            {
                AccountId = response1.AccountId,
                Title     = "a a 2015",
                ImageUri  = "localhost",
                StartDate = start,
                EndDate   = end,
                CloseDate = close,
                ExpectedEventCondition = "a a a a a 2015",
                EventRelationType      = EventRelationType.MenyVsMeny,
                ArbiterAccountIds      = new[] { response2.AccountId },
                AlgorithmType          = AlgorithmType.Exponential,
                StartRate    = 100,
                LocusRage    = 1,
                EndRate      = 0,
                CurrencyType = CurrencyType.Reputation
            });

            var response3 = await _eventsService.GetEvents(new GetEventsRequest { AccountId = response1.AccountId });

            Assert.IsTrue(response3.Events.Any(r => r.EventId == response.EventId));
        }
コード例 #2
0
        private async void LoadEvents()
        {
            if (Events != null)
            {
                return;
            }

            try
            {
                var response = await _eventsService.GetEvents();

                if (response.IsSuccess)
                {
                    Events = new ObservableCollection <EventsModel>(response.Data);
                }
                else
                {
                    await DisplayApiMessage(response);
                }
            }
            catch (System.Exception ex)
            {
                await DisplayError(ex);
            }
        }
コード例 #3
0
    private IEnumerator _GetEvents()
    {
        AlertsService.makeLoadingAlert("Recebendo eventos");
        WWW eventsRequest = EventsService.GetEvents();

        while (!eventsRequest.isDone)
        {
            yield return(new WaitForSeconds(0.1f));
        }

        Debug.Log("Header: " + eventsRequest.responseHeaders["STATUS"]);
        Debug.Log("Text: " + eventsRequest.text);
        AlertsService.removeLoadingAlert();

        if (eventsRequest.responseHeaders["STATUS"] == HTML.HTTP_200)
        {
            StartCoroutine(_GetUserEvents());
            EventsService.UpdateLocalEvents(eventsRequest.text);
            CreateEventCards();
        }
        else
        {
            AlertsService.makeAlert("Falha na conexão", "Tente novamente mais tarde.", "");
            yield return(new WaitForSeconds(3f));

            LoadView("Home");
        }

        yield return(null);
    }
コード例 #4
0
        public void GetEvents_Caches_Results()
        {
            //Arrange
            var eventsRepo = new StubIRepository<Event>()
            {
                All = () => EventTestData.SingleEvent.AsQueryable()
            };
            var cacheService = new DefaultMemoryCache();
            var eventService = new EventsService(eventsRepo, cacheService);

            //Act
            eventService.GetEvents();
            //Assert
            Assert.IsTrue(cacheService.Exists("events:all"));
        }
コード例 #5
0
 public HttpResponseMessage GetEvents([FromUri] PointDTO point, double radius)
 {
     try
     {
         if (point == null)
         {
             return(Request.CreateResponse(HttpStatusCode.BadRequest, "Illegal Parameters"));
         }
         List <MapEventDTO> list = EventsService.GetEvents(point, radius);
         return(Request.CreateResponse(HttpStatusCode.OK, list));
     }
     catch (Exception e)
     {
         return(Request.CreateResponse(HttpStatusCode.InternalServerError, "There was an InternalServerError: " + e));
     }
 }
コード例 #6
0
        public async Task <IActionResult> History()
        {
            var user = await _userManager.GetUserAsync(User);

            if (user == null)
            {
                await _signInManager.SignOutAsync();

                return(_notice.Error(this));
            }

            var model = new HistoryViewModel
            {
                Events = _events.GetEvents(user)
            };

            return(View(model));
        }
コード例 #7
0
        public void GetEvents_Returns_Results_From_Cache()
        {
            //arrange
            var cacheService = new StubICacheService()
            {
                ExistsString = (key) => true
            };

            cacheService.RetrieveOf1String<IEnumerable<Event>>(
                (key) => EventTestData.SingleEvent.AsEnumerable()
            );
            var eventsRepo = new StubIRepository<Event>();
            var eventService = new EventsService(eventsRepo, cacheService);

            //Act
            var results = eventService.GetEvents();
            Assert.AreEqual(results.Count(), EventTestData.SingleEvent.Count);
        }
コード例 #8
0
        public ActionResult Sync(ClientSyncData syncData)
        {
            try
            {
                if (syncData == null)
                {
                    return(null);
                }

                var eventsService = new EventsService();
                var userService   = new UserService();

                var dddEvents                = eventsService.GetEvents(syncData.dddEventListVersion);
                var dddEventDetails          = eventsService.GetEventDetails(syncData.dddEventDataInfo);
                var userGeneratedDataService = new UserGeneratedDataService(eventsService, userService, syncData.dddEventDataInfo);

                var acceptedSessionComments        = userGeneratedDataService.AddComments("session", syncData.clientToken, syncData.sessionComments);
                var acceptedEventMostLikeComments  = userGeneratedDataService.AddComments("eventMostLike", syncData.clientToken, syncData.eventMostLikeComments);
                var acceptedEventLeastLikeComments = userGeneratedDataService.AddComments("eventLeastLike", syncData.clientToken, syncData.eventLeastLikeComments);
                var acceptedEventComments          = userGeneratedDataService.AddComments("eventOverall", syncData.clientToken, syncData.eventComments);
                var acceptedPocketDDDComments      = userGeneratedDataService.AddComments("pocketDDD", syncData.clientToken, syncData.pocketDDDComments);
                userGeneratedDataService.AddOrUpdateSessionData(syncData.clientToken, syncData.userSessionData);
                userGeneratedDataService.AddOrUpdateEventData(syncData.clientToken, syncData.userEventData);
                var eventScores = userGeneratedDataService.CommitEventScores();

                var data = new SyncResult
                {
                    dddEventListVersion            = eventsService.GetEventListVersion(),
                    dddEvents                      = dddEvents,
                    dddEventDetails                = dddEventDetails,
                    acceptedSessionComments        = acceptedSessionComments,
                    acceptedEventMostLikeComments  = acceptedEventMostLikeComments,
                    acceptedEventLeastLikeComments = acceptedEventLeastLikeComments,
                    acceptedEventComments          = acceptedEventComments,
                    acceptedPocketDDDComments      = acceptedPocketDDDComments,
                    dddEventScores                 = eventScores
                };
                return(new JsonNetResult(data));
            }
            catch (Exception)
            {
                throw; // new InvalidDataException("Unable to sync");
            }
        }
コード例 #9
0
        public void GetEvents_Does_Not_Call_Repository_All_When_Cache_Available()
        {
            //arrange
            var cacheService = new DefaultMemoryCache();
            cacheService.Store("events:all", EventTestData.SingleEvent.AsQueryable());
            bool allWasCalled = false;
            var eventsRepo = new StubIRepository<Event>()
            {
                All = () =>
                {
                    allWasCalled = true;
                    return Enumerable.Empty<Event>().AsQueryable();
                }
            };
            var eventService = new EventsService(eventsRepo, cacheService);

            //Act
            var results = eventService.GetEvents();

            //Assert
            Assert.IsFalse(allWasCalled);
        }
コード例 #10
0
        public override async Task OnInitializing()
        {
            Items = await EventsService.GetEvents(refresher : Refresh); // BaseApi.Get<Event[]>(uri, cacheChoice: ApiResponseCache.PreferThenUpdate, refresher: Refresh);

            await base.OnInitializing();
        }