Пример #1
0
        public async Task TestCreateGetEventDetails()
        {
            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.GetEventDetails(new GetEventRequest { EventId = response.EventId });

            Assert.AreEqual("a a 2015", response3.Title);
            Assert.AreEqual(end, response3.EndDate);
            Assert.AreEqual(start, response3.StartDate);
        }
Пример #2
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");
            }
        }