Ejemplo n.º 1
0
        private int CreateEvent(PageRequestDto dto)
        {
            var eventRequest = new EventRequestDto
            {
                Name           = dto.EventName,
                Description    = dto.PageSummaryWhat,
                StartDate      = dto.EventDate,
                CompletionDate = dto.EventDate,
                ExpiryDate     = DateTime.Now.AddYears(1),
                EventType      = dto.ActivityType
            };

            return(Task.Factory.StartNew(() => CreateEventTask(eventRequest).Result, TaskCreationOptions.LongRunning).Result);
        }
Ejemplo n.º 2
0
        private async Task <int> CreateEventTask(EventRequestDto dto)
        {
            try
            {
                var url      = string.Format("{0}event", _endPoint);
                var response = _httpClient.PostAsJsonAsync(url, dto);
                response.Result.EnsureSuccessStatusCode();
                var content = await response.Result.Content.ReadAsStringAsync();

                var result = JsonHelper.Deserialize <EventResponseDto>(content);

                return(result.Id);
            }
            catch (Exception ex)
            {
                _loggingService.Log(string.Format("Error creating JustGiving event: {0}", ex.Message),
                                    LogLevel.Error);
            }

            return(0);
        }
 private int CreateEvent(PageRequestDto dto)
 {
     var eventRequest = new EventRequestDto
     {
         Name = dto.EventName,
         Description = dto.PageSummaryWhat,
         StartDate = dto.EventDate,
         CompletionDate = dto.EventDate,
         ExpiryDate = DateTime.Now.AddYears(1),
         EventType = dto.ActivityType
     };
     return Task.Factory.StartNew(() => CreateEventTask(eventRequest).Result, TaskCreationOptions.LongRunning).Result;
 }
        private async Task<int> CreateEventTask(EventRequestDto dto)
        {
            try
            {
                var url = string.Format("{0}event", _endPoint);
                var response = _httpClient.PostAsJsonAsync(url, dto);
                response.Result.EnsureSuccessStatusCode();
                var content = await response.Result.Content.ReadAsStringAsync();
                var result = JsonHelper.Deserialize<EventResponseDto>(content);

                return result.Id;
            }
            catch (Exception ex)
            {
                _loggingService.Log(string.Format("Error creating JustGiving event: {0}", ex.Message),
                    LogLevel.Error);
            }

            return 0;
        }