Exemplo n.º 1
0
        public static void RegisterAnalyseCompleteEvent(string projectId)
        {
            try
            {
                HttpClient client = new HttpClient();
                client.DefaultRequestHeaders
                .Accept
                .Add(new MediaTypeWithQualityHeaderValue("application/json"));

                CreateEventRequest requestObject = new CreateEventRequest()
                {
                    Event     = EventTypeWebEngage.CrawlerAnalysed,
                    ProjectId = projectId
                };
                var jsonData = JsonConvert.SerializeObject(requestObject);
                var response = client.PostAsync(String.Format(RegisterEventAPI, EnvironmentConstants.ApplicationConfiguration.APIDomain, projectId), new StringContent(jsonData, Encoding.UTF8, "application/json")).Result;
                if (response.StatusCode == System.Net.HttpStatusCode.Unauthorized)
                {
                    throw new Exception("UnAuthorized");
                }
                else if (!((int)response.StatusCode >= 200 && (int)response.StatusCode <= 300))//If status code is not 20X, error.
                {
                    throw new Exception(String.Format("API call unsuccessful : {0}", RegisterEventAPI));
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex, String.Format("Error updating kitsuneproject after Analyse completed, ProjectId:{0}", projectId));
            }
        }
Exemplo n.º 2
0
        public ActionResult <CreateEventService> Post(CreateEventRequest request)
        {
            CreateEventService  _service = new CreateEventService(_unitOfWork);
            CreateEventResponse response = _service.Execute(request);

            return(Ok(response));
        }
Exemplo n.º 3
0
        public ServiceResponse <int> CreateEvent(CreateEventRequest request)
        {
            var authResponse = _authService.GetCurrentUserId();

            if (authResponse.Failure)
            {
                return(Failure <int>());
            }

            var hasHabitResponse = _habitService.HasHabit(request.HabitId);

            if (hasHabitResponse.Failure || !hasHabitResponse.Payload)
            {
                return(Failure <int>());
            }

            var newEvent = new Event
            {
                HabitId     = request.HabitId,
                Timestamep  = request.Timestamp,
                Description = request.Description
            };

            _dataContext.Events.Add(newEvent);

            try
            { _dataContext.SaveChanges(); }
            catch (Exception)
            { return(Failure <int>()); }

            return(Success(newEvent.Id));
        }
Exemplo n.º 4
0
        /// <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);
        }
Exemplo n.º 5
0
        private void AddEvent(Subsequence sequence)
        {
            CreateEventRequest.Raise(
                new Confirmation
            {
                Title = "Add Event",
            },
                confirmation =>
            {
                if (confirmation.Confirmed)
                {
                    var evt = (Event)confirmation.Content;
                    switch (sequence)
                    {
                    case Subsequence.Primary:
                        Sequence.PrimarySequence.Add(evt);
                        break;

                    case Subsequence.Abort:
                        Sequence.AbortSequence.Add(evt);
                        break;

                    default:
                        break;
                    }
                }
            });
        }
Exemplo n.º 6
0
        public CreateEventResponse CreateEvent(string userId, string calendarId, CreateEventRequest request)
        {
            AlibabaCloud.TeaUtil.Models.RuntimeOptions runtime = new AlibabaCloud.TeaUtil.Models.RuntimeOptions();
            CreateEventHeaders headers = new CreateEventHeaders();

            return(CreateEventWithOptions(userId, calendarId, request, headers, runtime));
        }
Exemplo n.º 7
0
        public async Task <IActionResult> CreatEvent(CreateEventRequest request)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(new
                {
                    Code = "error",
                    Message = "error.create.event",
                    Error = "empty name"
                }));
            }

            var Event = new Event
            {
                About = request.About,
                //AddedDate = DateTime.Now
            };

            await _eventService.CreateEventAsync(Event);

            var response = new EventResponse
            {
                Code    = "success",
                Message = "create.event.success"
            };

            return(Ok(response));
        }
Exemplo n.º 8
0
        public EventModel Create(CreateEventRequest eventModel, string ownerToken)
        {
            if (_events.Find(e => e.Title == eventModel.Title).FirstOrDefault() == null)
            {
                var owner        = _users.Find(u => u.Token == ownerToken).FirstOrDefault();
                var createdEvent = new BackendEventModel(null, eventModel.Title, owner.City, eventModel.DetailLocation
                                                         , eventModel.Description, owner.Id, eventModel.Date, eventModel.Price);
                _events.InsertOne(createdEvent);
                _redisEventsDatabase.StringSet(createdEvent.Id, JsonConvert.SerializeObject(createdEvent), ttl);
                createdEvent = _convertModelsService.GetBackendEventModel(GetByTitle(eventModel.Title));

                if (eventModel.ImageArray != null)
                {
                    var imageUrl = UploadImage(createdEvent.Id, eventModel.ImageArray);
                    createdEvent.ImageUrl = imageUrl;
                    _events.ReplaceOne(e => e.Id == createdEvent.Id, createdEvent);
                    _redisEventsDatabase.StringSet(createdEvent.Id, JsonConvert.SerializeObject(createdEvent), ttl);
                }

                var list = new List <string>();
                if (owner.HostingEvents != null)
                {
                    list = owner.HostingEvents.ToList();
                }
                list.Add(createdEvent.Id);
                owner.HostingEvents = list.ToArray();
                _users.ReplaceOne(u => u.Id == owner.Id, owner);
                _redisUsersDatabase.StringSet(owner.Id, JsonConvert.SerializeObject(owner), ttl);

                return(_convertModelsService.GetEventModel(createdEvent));
            }


            return(null);
        }
Exemplo n.º 9
0
        public void CreateEventWithEmptyModel_ThrowsException()
        {
            var cmd     = new CreateEventCommand(_ctx);
            var request = new CreateEventRequest(new ReservationModel());

            Assert.Throws <ArgumentNullException>(() => cmd.Handle(request, CancellationToken.None).Wait());
        }
Exemplo n.º 10
0
        public async Task <ActionResult> Create(
            [FromRoute] long userId,
            [FromBody] CreateEventRequest createEventRequest)
        {
            InvoiceService invoiceService = new InvoiceService(_invoiceRepository);

            //Get charge domain service
            ChargeService chargeService = new ChargeService(
                _chargeRepository,
                _eventTypeRepository,
                _userRepository,
                invoiceService);

            try
            {
                //Create new charge and attach event to it
                Charge createdCharge = await chargeService.CreateChargeWithEvent(
                    createEventRequest.Amount,
                    createEventRequest.Currency,
                    userId,
                    createEventRequest.EventTypeName);

                await _dbContext.SaveChangesAsync();

                return(Ok(createdCharge));
            }
            catch (InvalidEntityException ex)
            {
                return(BadRequest(_mapper.Map <CreateEventFailedResponse>(ex.Model)));
            }
        }
Exemplo n.º 11
0
        public ActionResult <ResponseModel <EventModel> > Create(CreateEventRequest eventModel, [FromHeader] string Authorization)
        {
            string token = Authorization.Split()[1];
            var    Event = _eventService.Create(eventModel, token);

            return(ResponseModel <EventModel> .FormResponse("event", Event, "Unable to create event"));
        }
Exemplo n.º 12
0
        public async Task <IActionResult> CreateEvent([FromBody] CreateEventRequest request)
        {
            var createEventCommand = new CreateEventCommand(request);
            var result             = await mediator.Send(createEventCommand);

            return(StatusCode((int)result.Code, result.Value));
        }
Exemplo n.º 13
0
        public async Task GetBetsByEvent()
        {
            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 ev = 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 ceResponse1 = await _eventsService.CreateEvent(ev);

            var req = new CreateBetRequest {
                EventId = ceResponse1.EventId, OutcomesType = OutcomesType.NotHappen
            };

            req.AccountId = response3.AccountId;
            await _betsService.CreateBet(req);

            req.AccountId = response4.AccountId;
            await _betsService.CreateBet(req);

            req.AccountId = response5.AccountId;
            await _betsService.CreateBet(req);

            req.AccountId = response6.AccountId;
            await _betsService.CreateBet(req);

            var response7 = await _betsService.GetBets(new GetBetsRequest { EventId = req.EventId });

            Assert.AreEqual(4, response7.Bets.Count());
        }
Exemplo n.º 14
0
        /// <summary>
        /// Create notification event
        /// </summary>
        /// <param name="сreateEventRequest">The сreate event parameter.</param>
        /// <returns>Success HTTP Status Code 201</returns>
        public async Task <HttpResponse <EventResponse> > CreateEventAsync(CreateEventRequest сreateEventRequest)
        {
            var resultPushTokenResponse = await HttpService.PostAsync <EventResponse, CreateEventRequest>(this.quickbloxClient.ApiEndPoint,
                                                                                                          QuickbloxMethods.EventsMethod,
                                                                                                          сreateEventRequest,
                                                                                                          RequestHeadersBuilder.GetDefaultHeaders().GetHeaderWithQbToken(this.quickbloxClient.Token));

            return(resultPushTokenResponse);
        }
Exemplo n.º 15
0
        public async Task <CreateEventResponse> CreateEvent(CreateEventRequest request)
        {
            GetAccountResponse accountResponse = await this._accountingService.GetAccount(new GetAccountRequest { AccountId = request.AccountId });

            EventRelationType relatonType = await this._repositoryEventRelationType.GetBy(t => t.Name == request.EventRelationType);

            CurrencyType currencyType = await this._repositoryCurrencyType.GetBy(t => t.Name == request.CurrencyType);

            AlgorithmType algorithmType = await this._repositoryAlgorithmType.GetBy(t => t.Name == request.AlgorithmType);

            await Check(accountResponse.AccountId, request);

            using (this._scopeableFactory.Create())
            {
                var arbiterAccountSetResponse = await this._accountingService.CreateAccountsSet(
                    new CreateAccountsSetRequest
                {
                    CreatorAccountId = accountResponse.AccountId,
                    AccountIds       = request.ArbiterAccountIds
                });

                var arbiterAccountSet = await this._repositoryAccountSet.Get(arbiterAccountSetResponse.Id);

                var participantsAccountSetResponse = await this._accountingService.CreateAccountsSet(
                    new CreateAccountsSetRequest
                {
                    CreatorAccountId = accountResponse.AccountId,
                    AccountIds       = request.ParticipantsAccountIds
                });

                var participantsAccountSet = await this._repositoryAccountSet.Get(participantsAccountSetResponse.Id);

                var account = await this._repositoryAccount.Get(accountResponse.AccountId);

                var eventCondition = await this._eventsFactory.CreateEventCondition(account, request.ExpectedEventCondition);

                var betRateAlgorithm = await this._eventsFactory.CreateEventBetRateAlgorithm(account, algorithmType, request.StartRate, request.EndRate, request.LocusRage);

                var betCondition = await this._eventsFactory.CreateEventBetCondition(account, currencyType, betRateAlgorithm, request.CloseDate);

                var @event = await this._eventsFactory.CreateEvent(
                    account,
                    arbiterAccountSet,
                    participantsAccountSet,
                    eventCondition,
                    relatonType,
                    betCondition,
                    request.Title,
                    request.StartDate,
                    request.EndDate);

                return(new CreateEventResponse {
                    EventId = @event.Id
                });
            }
        }
Exemplo n.º 16
0
        public ActionResult AddEvent(CreateEventRequest createRequest)
        {
            var newEvent = _eventRepository.AddEvent(
                createRequest.Description,
                createRequest.Location,
                createRequest.Year,
                createRequest.IsCorrect);

            return(Created($"/api/event/{newEvent.Id}", newEvent));
        }
Exemplo n.º 17
0
 public static CreateEvent ToCommand(this CreateEventRequest request)
 {
     return(new CreateEvent(
                name: request.Name,
                description: request.Description,
                location: request.Location,
                startTime: request.StartTime,
                endTime: request.EndTime
                ));
 }
Exemplo n.º 18
0
        public async Task <ActionResult <long> > Create([FromBody] CreateEventRequest request)
        {
            var command         = new CreateEventCommand(request.Name, request.Dates);
            var eventCreatedDto = await _mediator.Send(command);

            return(CreatedAtAction(
                       nameof(GetById),
                       new { version = "1.0", id = eventCreatedDto.Id },
                       eventCreatedDto));
        }
Exemplo n.º 19
0
 public Event CreateEventRequestToEvent(CreateEventRequest createEventRequest)
 {
     return(new Event
     {
         Name = createEventRequest.Name,
         Date = createEventRequest.Date,
         Description = createEventRequest.Description,
         PlaceId = createEventRequest.PlaceId,
         TypeId = createEventRequest.TypeId
     });
 }
        public IActionResult CreateEvent([FromRoute] Guid trackId, [FromBody] CreateEventRequest request)
        {
            var userId         = User.GetUserId();
            var customizations = _mapper.Map <CustomizationsDto>(request.Customizations);

            var @event = _eventService.CreateEvent(userId, trackId, request.CreatedAt, customizations);

            var result = _mapper.Map <EventModel>(@event);

            return(Ok(result));
        }
Exemplo n.º 21
0
        /// <summary>
        /// 创建测试事件
        /// </summary>
        public async Task <CreateEventResponse> CreateEventAsync(CreateEventRequest createEventRequest)
        {
            Dictionary <string, string> urlParam = new Dictionary <string, string>();

            urlParam.Add("function_urn", createEventRequest.FunctionUrn.ToString());
            string              urlPath  = HttpUtils.AddUrlPath("/v2/{project_id}/fgs/functions/{function_urn}/events", urlParam);
            SdkRequest          request  = HttpUtils.InitSdkRequest(urlPath, "application/json", createEventRequest);
            HttpResponseMessage response = await DoHttpRequestAsync("POST", request);

            return(JsonUtils.DeSerialize <CreateEventResponse>(response));
        }
Exemplo n.º 22
0
 public void Execute(CreateEventRequest request)
 {
     using (var db = databaseFactory.CreateNew())
     {
         var ev = new IngrEvent {
             ChatId = request.ChatId, Start = request.Start, Finished = request.Finished, LocationId = request.LocationId, TypeId = request.EventTypeId
         };
         db.IngrEvents.Add(ev);
         db.SaveChanges();
     }
 }
Exemplo n.º 23
0
        public ActionResult <int> AddEvent(CreateEventRequest createRequest)
        {
            if (!_validator.Validate(createRequest))
            {
                return(BadRequest(new { error = "users must have a name and date" }));
            }

            var newLeapee = _eventRepository.AddEvent(createRequest.EventName, createRequest.EventDate);

            return(Created($"api/event/{newLeapee.Id}", newLeapee));
        }
        public async Task <IActionResult> CreateEvent([FromBody] CreateEventRequest request)
        {
            var command = request.ToCommand();
            await dispatcher.DispatchAsync(command);

            return(new ContentResult
            {
                ContentType = "application/json",
                Content = command.CreatedId.ToString(),
                StatusCode = (int)HttpStatusCode.Created
            });
        }
Exemplo n.º 25
0
        protected async Task <EventGetByIdResponse> CreateEventAsync(CreateEventRequest request)
        {
            var response = await TestClient.PostAsJsonAsync(ApiRoutes.Event.CreateEvent, request);

            var responseModel = new EventGetByIdResponse
            {
                Code    = "success",
                Message = "success.create.event",
            };

            return(responseModel);
        }
Exemplo n.º 26
0
        public ActionResult AddEvent(CreateEventRequest createRequest)
        {
            if (_validator.Validate(createRequest))
            {
                return(BadRequest(new { error = "users must have a name and event location" }));
            }

            var newEvent = _eventRepository.AddEvent(createRequest.Name,
                                                     createRequest.EventTime,
                                                     createRequest.EventLocation,
                                                     createRequest.NameOfEvent);

            return(Created($"api/event/{newEvent.Id}", newEvent));
        }
Exemplo n.º 27
0
        public ActionResult Post(CreateEventRequest request)
        {
            try
            {
                var eventReq = Mapper.Map <EventDTO>(request.Event);
                var created  = _serviceUow.EventService.SaveEvent(Mapper.Map <Event>(eventReq));

                return(Created("/Event", Mapper.Map <EventDTO>(created)));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
Exemplo n.º 28
0
        public void CreateNew_WhenLocationIsNotValid_ShouldThrowUseCaseException()
        {
            //ARRANGE
            const string userName         = "******";
            const string eventDescription = "event description";
            const string eventName        = "event name";
            const string locationName     = "Skolas iela, Riga, Latvia";
            const double latitude         = 22;
            const double longitude        = 33;
            DateTime?    eventStart       = new DateTime(1999, 12, 1);
            DateTime?    eventEnd         = new DateTime(1999, 12, 2);
            var          memberId         = new Guid("41FEB6C1-DA81-4E9D-8ABA-63665DF0B9CC");
            var          categoryId       = new Guid("7BC0C011-7FA3-4AA4-B260-257465831D65");

            var coordServiceResult = new CoordServiceResult
            {
                Latitude  = latitude,
                Longitude = longitude,
                Message   = "location message",
                Success   = false
            };

            var createEventRequest = new CreateEventRequest
            {
                Categories = new List <CategoryDto> {
                    new CategoryDto {
                        CategoryId = categoryId
                    }
                },
                Locations = new List <LocationDto>
                {
                    new LocationDto {
                        EventStart = eventStart, EventEnd = eventEnd, Name = locationName
                    }
                },
                Members = new List <MemberDto> {
                    new MemberDto {
                        Id = memberId
                    }
                },
                Name        = eventName,
                Description = eventDescription
            };

            _coordServiceMock.Setup(cs => cs.Lookup(locationName))
            .ReturnsAsync(coordServiceResult);

            //ACT & ASSERT
            Assert.ThrowsAsync <UseCaseException>(() => _eventService.Create(createEventRequest, userName));
        }
Exemplo n.º 29
0
        private Task Check(Guid accountId, CreateEventRequest request)
        {
            if (request.ArbiterAccountIds.Any(id => id == accountId))
            {
                throw new InvalidOperationException("Arbiter account has you accountId");
            }

            if (request.ArbiterAccountIds.Intersect(request.ParticipantsAccountIds).Any())
            {
                throw new InvalidOperationException("Arbiter accounts should not intersect with participants account");
            }

            return(Task.FromResult(true));
        }
Exemplo n.º 30
0
        public async Task Create(CreateEventRequest request, string userName)
        {
            _logger.LogInformation($"Creating event for user {userName}, request: {request}");

            var newEvent = _mapper.Map <Event>(request);

            newEvent.UserName = userName;

            await ValidateLocations(newEvent.Locations);

            _eventRepository.AddEvent(newEvent);

            await EnsureEventCreatedInDatabase();
        }
Exemplo n.º 31
0
 public CreateEventViewModel Get(CreateEventRequest request)
 {
     return new CreateEventViewModel();
 }