private static DtoIssue CreateTestDtoIssue()
        {
            var i = new DtoIssue()
            {
                ProjectId   = 165,
                Title       = "My Test Ticket",
                Description = "Test Description for Ticket",
                TrackerId   = 2,
                StatusId    = 1,
                PriorityId  = 4,
                AssigneeId  = 127
            };

            return(i);
        }
Ejemplo n.º 2
0
        private static DtoIssue Map(SimpleIssue issue)
        {
            // TODO: Validate Title
            // TODO: Validate Description

            var mappedIssue = new DtoIssue()
            {
                ProjectId   = _config.ConfiguredProject.ProjectId,
                TrackerId   = _config.ConfiguredProject.TrackerId,
                StatusId    = _config.ConfiguredProject.StatusId,
                PriorityId  = _config.ConfiguredProject.PriorityId,
                Title       = issue.Title,
                Description = issue.Description
            };

            if (_config.ConfiguredProject.CustomFields != null)
            {
                mappedIssue.CustomFields = _config.ConfiguredProject.CustomFields;
            }

            return(mappedIssue);
        }
Ejemplo n.º 3
0
        private static async Task <(bool Success, string ResponseMessage, RedmineFullIssue CreatedIssue)> CreateIssue(DtoIssue issue)
        {
            // TODO: Call CreateRedmineIssue
            HttpClientInstance.Init(_config.CreateRedmineIssueUrl, null);
            var _client = HttpClientInstance.Instance;

            var resp = await _client.PostAsJsonAsync(_config.CreateRedmineIssueEndPoint, issue);

            var success = resp.IsSuccessStatusCode;

            string json = null;

            if (success)
            {
                json = await resp.Content.ReadAsStringAsync();

                if (!String.IsNullOrWhiteSpace(json))
                {
                    try
                    {
                        var ret = JsonConvert.DeserializeObject <RedmineFullIssue>(json);
                        return(Success : success, ResponseMessage : "Successful", CreatedIssue : ret);
                    }
                    catch (Exception ex)
                    {
                        success = false;
                        return(Success : success, ResponseMessage : ex.Message, CreatedIssue : null);
                    }
                }
                else
                {
                    success = false;
                    return(Success : success, ResponseMessage : "Empty Content from Redmine.", CreatedIssue : null);
                }
            }
            else
            {
                var error = await resp.Content.ReadAsStringAsync();

                return(Success : success, ResponseMessage : error, CreatedIssue : null);
            }
        }