Esempio n. 1
0
        public override async Task ConfigureAsync(IOperationExecutionContext context)
        {
            var gitlab = new GitLabClient(this.Template.ApiUrl, this.Template.UserName, this.Template.Password, this.Template.GroupName);
            var id     = await gitlab.CreateMilestoneAsync(this.Template.Title, this.Template.ProjectName, context.CancellationToken).ConfigureAwait(false);

            var data = new Dictionary <string, object> {
                ["title"] = this.Template.Title
            };

            if (this.Template.StartDate != null)
            {
                data.Add("start_date", AH.NullIf(this.Template.StartDate, string.Empty));
            }
            if (this.Template.DueDate != null)
            {
                data.Add("due_date", AH.NullIf(this.Template.DueDate, string.Empty));
            }
            if (this.Template.Description != null)
            {
                data.Add("description", this.Template.Description);
            }
            if (this.Template.State.HasValue)
            {
                data.Add("state_event", this.Template.State == GitLabMilestoneConfiguration.OpenOrClosed.open ? "activate" : "close");
            }

            await gitlab.UpdateMilestoneAsync(id, this.Template.ProjectName, data, context.CancellationToken).ConfigureAwait(false);
        }