コード例 #1
0
        public string CreatePage(PageRequestDto dto)
        {
            dto.CharityId = _charityId;
            if (dto.EventId != null)
            {
                return(Task.Factory.StartNew(() => CreatePageTask(dto).Result, TaskCreationOptions.LongRunning).Result);
            }

            var activityType = (ActivityType)Enum.Parse(typeof(ActivityType), dto.ActivityType, true);

            switch (activityType)
            {
            case ActivityType.Birthday:
            case ActivityType.InMemory:
            case ActivityType.OtherCelebration:
            case ActivityType.Wedding:
                break;

            default:
                dto.EventId = CreateEvent(dto);
                break;
            }

            return(Task.Factory.StartNew(() => CreatePageTask(dto).Result, TaskCreationOptions.LongRunning).Result);
        }
コード例 #2
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);
        }
コード例 #3
0
        private async Task <string> CreatePageTask(PageRequestDto dto)
        {
            try
            {
                var url      = string.Format("{0}fundraising/pages", _endPoint);
                var response = _httpClient.PutAsJsonAsync(url, dto);
                response.Result.EnsureSuccessStatusCode();
                var content = await response.Result.Content.ReadAsStringAsync();

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

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

            return(string.Empty);
        }
コード例 #4
0
        public string CreatePage(PageRequestDto dto)
        {
            dto.CharityId = _charityId;
            if (dto.EventId != null)
            {
                return Task.Factory.StartNew(() => CreatePageTask(dto).Result, TaskCreationOptions.LongRunning).Result;
            }

            var activityType = (ActivityType)Enum.Parse(typeof(ActivityType), dto.ActivityType, true);
            switch (activityType)
            {
                case ActivityType.Birthday:
                case ActivityType.InMemory:
                case ActivityType.OtherCelebration:
                case ActivityType.Wedding:
                    break;
                default:
                    dto.EventId = CreateEvent(dto);
                    break;
            }

            return Task.Factory.StartNew(() => CreatePageTask(dto).Result, TaskCreationOptions.LongRunning).Result;
        }
コード例 #5
0
        public override WorkflowExecutionStatus Execute(Record record, RecordEventArgs e)
        {
            var values = JsonHelper.Deserialize<MappingDto>(Mappings);
            foreach (var mapping in values.Mappings)
            {
                switch (mapping.Alias)
                {
                    case MappingAliases.JustGiving.EventId:
                        break;
                }
            }

            const string Username = "******";
            const string Password = "******";
            var page = new PageRequestDto();
            if (!JustGivingService.ValidateCredentials(Username, Password))
            {
                return WorkflowExecutionStatus.Failed;
            }

            var pageUrl = CreatePage(Username, Password, page);
            return string.IsNullOrEmpty(pageUrl) ? WorkflowExecutionStatus.Failed : WorkflowExecutionStatus.Completed;
        }
コード例 #6
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;
 }
コード例 #7
0
        private async Task<string> CreatePageTask(PageRequestDto dto)
        {
            try
            {
                var url = string.Format("{0}fundraising/pages", _endPoint);
                var response = _httpClient.PutAsJsonAsync(url, dto);
                response.Result.EnsureSuccessStatusCode();
                var content = await response.Result.Content.ReadAsStringAsync();
                var result = JsonHelper.Deserialize<PageResponseDto>(content);

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

            return string.Empty;
        }
コード例 #8
0
        private string CreatePage(string username, string password, PageRequestDto page)
        {
            try
            {
                if (JustGivingService.ValidateCredentials(username, password))
                {
                    return JustGivingService.CreatePage(page);
                }
            }
            catch (Exception ex)
            {
                _loggingService.Log(string.Format("Failure creating JustGiving fundraising page: {0}", ex.Message), LogLevel.Error);
            }

            return string.Empty;
        }