/// <summary> /// Create new meeting for given room. /// </summary> /// <param name="eventRequest"><see cref="CreateEventRequest"/> object. </param> /// <param name="token">Active Directory access token.</param> /// <returns>Event response object.</returns> public async Task <CreateEventResponse> CreateMeetingAsync(CreateEventRequest eventRequest, string token) { var eventRequestPayload = JsonConvert.SerializeObject(eventRequest); Dictionary <string, string> header = new Dictionary <string, string> { { "Prefer", "outlook.timezone=\"" + eventRequest.End.TimeZone + "\"" }, }; var httpResponseMessage = await this.apiHelper.PostAsync(this.graphAPIEvents, token, eventRequestPayload, header).ConfigureAwait(false); var content = await httpResponseMessage.Content.ReadAsStringAsync(); if (httpResponseMessage.IsSuccessStatusCode) { return(JsonConvert.DeserializeObject <CreateEventResponse>(content)); } var errorResponse = JsonConvert.DeserializeObject <ErrorResponse>(content); this.telemetryClient.TrackTrace($"Graph API failure- url: {this.graphAPIEvents}, response-code: {errorResponse.Error.StatusCode}, response-content: {errorResponse.Error.ErrorMessage}, request-id: {errorResponse.Error.InnerError.RequestId}", SeverityLevel.Warning); var failureResponse = new CreateEventResponse { StatusCode = httpResponseMessage.StatusCode, ErrorResponse = errorResponse, }; return(failureResponse); }
public async Task TestCreateBetParticipantsArbiterIntersectEx() { 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.OneVsMeny, ArbiterAccountIds = new[] { response2.AccountId }, ParticipantsAccountIds = new[] { response2.AccountId }, AlgorithmType = AlgorithmType.Exponential, StartRate = 100, LocusRage = 1, EndRate = 0, CurrencyType = CurrencyType.Reputation }); }
public async Task TestCalculateBetRate() { 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 response8 = await _betsService.CalculateBetRate(new CalculateBetRateRequest { BetAmount = 1, AccountId = response1.AccountId, EventId = response.EventId, OutcomesType = OutcomesType.Happen }); Assert.IsTrue(DateTime.Now > response8.CreationDate && DateTime.Now.AddSeconds(-10) < response8.CreationDate); Assert.AreEqual(0, response8.WinValue); Assert.IsTrue(0.9 < (double)response8.Rate); }
public async Task TestCreateEventError1() { var start = DateTime.Now; var end = new DateTime(2015, 1, 25); var close = start.AddDays((end - start).TotalDays / 2); var accountId = Guid.Empty; CreateEventResponse response = await _eventsService.CreateEvent(new CreateEventRequest { AccountId = 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[] { accountId }, AlgorithmType = AlgorithmType.Exponential, StartRate = 100, LocusRage = 1, EndRate = 0, CurrencyType = CurrencyType.Reputation }); }
public async Task TestCreateBet() { 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 response4 = await _betsService.CreateBet(new CreateBetRequest { AccountId = response1.AccountId, EventId = response.EventId, OutcomesType = OutcomesType.Happen }); Assert.AreNotEqual(Guid.Empty, response4.BetId); }
public static CreateEventResponse Unmarshall(UnmarshallerContext context) { CreateEventResponse createEventResponse = new CreateEventResponse(); createEventResponse.HttpResponse = context.HttpResponse; createEventResponse.Code = context.StringValue("CreateEvent.Code"); createEventResponse.Message = context.StringValue("CreateEvent.Message"); createEventResponse.RequestId = context.StringValue("CreateEvent.RequestId"); createEventResponse.Action = context.StringValue("CreateEvent.Action"); CreateEventResponse.CreateEvent__Event _event = new CreateEventResponse.CreateEvent__Event(); _event.Id = context.LongValue("CreateEvent.Event.Id"); _event.IdStr = context.StringValue("CreateEvent.Event.IdStr"); _event.Title = context.StringValue("CreateEvent.Event.Title"); _event.BannerPhotoId = context.StringValue("CreateEvent.Event.BannerPhotoId"); _event.Identity = context.StringValue("CreateEvent.Event.Identity"); _event.SplashPhotoId = context.StringValue("CreateEvent.Event.SplashPhotoId"); _event.State = context.StringValue("CreateEvent.Event.State"); _event.WeixinTitle = context.StringValue("CreateEvent.Event.WeixinTitle"); _event.WatermarkPhotoId = context.StringValue("CreateEvent.Event.WatermarkPhotoId"); _event.StartAt = context.LongValue("CreateEvent.Event.StartAt"); _event.EndAt = context.LongValue("CreateEvent.Event.EndAt"); _event.Ctime = context.LongValue("CreateEvent.Event.Ctime"); _event.Mtime = context.LongValue("CreateEvent.Event.Mtime"); _event.ViewsCount = context.LongValue("CreateEvent.Event.ViewsCount"); _event.LibraryId = context.StringValue("CreateEvent.Event.LibraryId"); _event.IdStr1 = context.StringValue("CreateEvent.Event.IdStr"); createEventResponse._Event = _event; return(createEventResponse); }
private void AssertsForSpecificTimeType(CreateEventResponse response, TimeType timeType, DurationType?durationType = null, DateTime?start = null, DateTime?end = null, int?duration = null) { Assert.IsNotNull(response.EventCreated.EventTime); Assert.AreEqual(timeType, response.EventCreated.EventTime.TimeType); switch (timeType) { case TimeType.Date: { Assert.AreEqual(start, response.EventCreated.EventTime.Start); Assert.AreEqual(end, response.EventCreated.EventTime.End); Assert.IsNull(response.EventCreated.EventTime.DurationType); Assert.IsNull(response.EventCreated.EventTime.Duration); break; } case TimeType.Duration: { Assert.AreEqual(durationType, response.EventCreated.EventTime.DurationType); Assert.AreEqual(duration, response.EventCreated.EventTime.Duration); Assert.IsNull(response.EventCreated.EventTime.Start); Assert.IsNull(response.EventCreated.EventTime.End); break; } } }
private EventDTO BuildEvent(CreateEventResponse data) { try { return(new EventDTO() { Assignments = data.Assignments, TeamId = data.TeamId, DurationInMinutes = data.DurationInMinutes, Id = data.Id, IsCanceled = data.IsCanceled, IsTimeTbd = data.IsTimeTbd, Location = data.Location, LocationDetails = data.LocationDetails, Notes = data.Notes, StartDate = data.StartDate, Name = data.Name, RepeatingType = data.RepeatingType, RepeatsUntil = data.RepeatsUntil, ShortLabel = data.ShortLabel }); } catch (Exception exc) { throw new InvalidOperationException("SchedulingService BuildEvent()", exc); } }
public async Task <Guid> CreateEvent(EventBindingModel model) { IUser account = await this._userManager.FindByIdAsync(User.Identity.GetUserId()); CreateEventResponse response = await this._eventsService.CreateEvent(new CreateEventRequest { AccountId = Guid.Parse(account.Id), AlgorithmType = model.AlgorithmType, CloseDate = model.CloseDate, CurrencyType = model.CurrencyType, EndDate = model.EndDate, EndRate = model.EndRate, EventRelationType = model.EventRelationType, ExpectedEventCondition = model.ExpectedEventCondition, ImageUri = model.ImageUri, ArbiterAccountIds = (await this.MatchesAccounts(model.ArbiterAccounts)).Select(a => Guid.Parse(a.Id)), LocusRage = model.LocusRage, ParticipantsAccountIds = (await this.MatchesAccounts(model.ParticipantsAccounts)).Select(a => Guid.Parse(a.Id)), StartDate = model.StartDate, StartRate = model.StartRate, Title = model.Title }); return(response.EventId); }
public ActionResult <CreateEventService> Post(CreateEventRequest request) { CreateEventService _service = new CreateEventService(_unitOfWork); CreateEventResponse response = _service.Execute(request); return(Ok(response)); }
private void AssertsForEachCorrectEvent(CreateEventResponse response, Guid?assetId) { Assert.IsNotNull(response); Assert.IsTrue(response.Success); Assert.IsNotNull(response.EventCreated); Assert.AreEqual(_eventId, response.EventCreated.EventId); Assert.AreEqual(assetId, response.EventCreated.AssetId); Assert.AreEqual(_articleId, response.EventCreated.ArticleId); Assert.AreEqual(_tenantId, response.EventCreated.TenantId); Assert.AreEqual(_purposeId, response.EventCreated.PurposeId); Assert.AreEqual(_hasUserAssetAssignment, response.EventCreated.HasUserAssetAssignment); Assert.AreEqual(_locationComment, response.EventCreated.LocationComment); Assert.AreEqual(_isConfirmed, response.EventCreated.IsConfirmed); Assert.AreEqual(_comment, response.EventCreated.Comment); }
public Task <EventDTO> CreateNewEventAsync(ManageEventDataModel newEventDataModel, CancellationTokenSource cancellationTokenSource) => Task <EventDTO> .Run(async() => { if (!CrossConnectivity.Current.IsConnected) { throw new InvalidOperationException(AppConsts.ERROR_INTERNET_CONNECTION); } EventDTO createdEvent = null; CreateEventRequest createEventRequest = new CreateEventRequest() { AccessToken = GlobalSettings.Instance.UserProfile.AccesToken, Data = newEventDataModel, Url = GlobalSettings.Instance.Endpoints.ScheduleEndpoints.CreateNewEvent }; try { CreateEventResponse createEventResponse = await _requestProvider.PostAsync <CreateEventRequest, CreateEventResponse>(createEventRequest); if (createEventResponse != null) { createdEvent = BuildEvent(createEventResponse); } else { throw new InvalidOperationException(CREATE_NEW_EVENT_COMMON_ERROR_MESSAGE); } } catch (HttpRequestExceptionEx exc) { CreateEventResponse createGameBadResponse = JsonConvert.DeserializeObject <CreateEventResponse>(exc.Message); string output = string.Format("{0}", createGameBadResponse.Errors?.FirstOrDefault()); output = (string.IsNullOrWhiteSpace(output) || string.IsNullOrEmpty(output)) ? CREATE_NEW_EVENT_COMMON_ERROR_MESSAGE : output.Trim(); throw new InvalidOperationException(output); } catch (Exception exc) { Crashes.TrackError(exc); throw; } return(createdEvent); }, cancellationTokenSource.Token);
private void OnCreateEvent(CreateEventResponse response, Dictionary <string, object> customData) { Log.Debug("TestDiscovery.OnCreateEvent()", "Response: {0}", customData["json"].ToString()); _createEventTested = true; }
public async Task TestCalculateCoupleBetRate() { 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 }); var response3 = await _accountingService.CreateAccount(new CreateAccountRequest { Email = this.UniqueEmail }); var response4 = await _accountingService.CreateAccount(new CreateAccountRequest { Email = this.UniqueEmail }); var response5 = await _accountingService.CreateAccount(new CreateAccountRequest { Email = this.UniqueEmail }); var response6 = await _accountingService.CreateAccount(new CreateAccountRequest { Email = this.UniqueEmail }); var response7 = 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 createBetRequest = new CreateBetRequest { EventId = response.EventId }; var calculateBetRateRequest = new CalculateBetRateRequest { BetAmount = 1, EventId = response.EventId }; calculateBetRateRequest.AccountId = response1.AccountId; calculateBetRateRequest.OutcomesType = OutcomesType.Happen; var calculateBetRateResponse = await _betsService.CalculateBetRate(calculateBetRateRequest); Assert.IsTrue(DateTime.Now > calculateBetRateResponse.CreationDate && DateTime.Now.AddSeconds(-10) < calculateBetRateResponse.CreationDate); Assert.AreEqual(0, calculateBetRateResponse.WinValue); Assert.IsTrue(0.99 < (double)calculateBetRateResponse.Rate); createBetRequest.AccountId = response1.AccountId; createBetRequest.OutcomesType = OutcomesType.Happen; var createBetResponse = await _betsService.CreateBet(createBetRequest); calculateBetRateRequest.AccountId = response3.AccountId; calculateBetRateResponse = await _betsService.CalculateBetRate(calculateBetRateRequest); Assert.AreEqual(0, calculateBetRateResponse.WinValue); Assert.IsTrue(0.99 / 2 < (double)calculateBetRateResponse.Rate); createBetRequest.AccountId = response3.AccountId; createBetResponse = await _betsService.CreateBet(createBetRequest); calculateBetRateRequest.AccountId = response4.AccountId; calculateBetRateResponse = await _betsService.CalculateBetRate(calculateBetRateRequest); Assert.AreEqual(0, calculateBetRateResponse.WinValue); Assert.IsTrue(0.99 / 3 < (double)calculateBetRateResponse.Rate); createBetRequest.AccountId = response4.AccountId; createBetResponse = await _betsService.CreateBet(createBetRequest); calculateBetRateRequest.AccountId = response5.AccountId; calculateBetRateRequest.OutcomesType = OutcomesType.NotHappen; calculateBetRateResponse = await _betsService.CalculateBetRate(calculateBetRateRequest); Assert.AreEqual(3, calculateBetRateResponse.WinValue); Assert.IsTrue(0.99 < (double)calculateBetRateResponse.Rate); createBetRequest.AccountId = response5.AccountId; createBetRequest.OutcomesType = OutcomesType.NotHappen; createBetResponse = await _betsService.CreateBet(createBetRequest); calculateBetRateRequest.AccountId = response6.AccountId; calculateBetRateResponse = await _betsService.CalculateBetRate(calculateBetRateRequest); Assert.IsTrue(1.5m > calculateBetRateResponse.WinValue && calculateBetRateResponse.WinValue > 1.49m); Assert.IsTrue(0.99 / 2 < (double)calculateBetRateResponse.Rate); createBetRequest.AccountId = response6.AccountId; createBetResponse = await _betsService.CreateBet(createBetRequest); calculateBetRateRequest.AccountId = response7.AccountId; calculateBetRateRequest.OutcomesType = OutcomesType.Happen; calculateBetRateResponse = await _betsService.CalculateBetRate(calculateBetRateRequest); Assert.IsTrue(0.5m > calculateBetRateResponse.WinValue && calculateBetRateResponse.WinValue > 0.49m); Assert.IsTrue(0.99 / 4 < (double)calculateBetRateResponse.Rate); }