Files
octokit.net/Octokit/Models/Response/Issue.cs
Haacked f3d4b751cc Make Issue readonly and fix a bug
Found a bug in which we were using Name when we should be using Login.
2015-01-03 20:22:31 -08:00

118 lines
3.2 KiB
C#

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Linq;
namespace Octokit
{
[DebuggerDisplay("{DebuggerDisplay,nq}")]
public class Issue
{
/// <summary>
/// The URL for this milestone.
/// </summary>
public Uri Url { get; protected set; }
public Uri HtmlUrl { get; protected set; }
/// <summary>
/// The issue number.
/// </summary>
public int Number { get; protected set; }
/// <summary>
/// Whether the issue is open or closed.
/// </summary>
public ItemState State { get; protected set; }
/// <summary>
/// Title of the issue
/// </summary>
public string Title { get; protected set; }
/// <summary>
/// Details about the issue.
/// </summary>
public string Body { get; protected set; }
/// <summary>
/// The user that created the issue.
/// </summary>
public User User { get; protected set; }
/// <summary>
/// The set of labels applied to the issue
/// </summary>
public IReadOnlyCollection<Label> Labels { get; protected set; }
/// <summary>
/// The user this issue is assigned to.
/// </summary>
public User Assignee { get; protected set; }
/// <summary>
/// The milestone, if any, that this issue is assigned to.
/// </summary>
public Milestone Milestone { get; protected set; }
/// <summary>
/// The number of comments on the issue.
/// </summary>
public int Comments { get; protected set; }
public PullRequest PullRequest { get; protected set; }
/// <summary>
/// The date the issue was closed if closed.
/// </summary>
public DateTimeOffset? ClosedAt { get; protected set; }
/// <summary>
/// The date the issue was created.
/// </summary>
public DateTimeOffset CreatedAt { get; protected set; }
/// <summary>
/// The date the issue was last updated.
/// </summary>
public DateTimeOffset? UpdatedAt { get; protected set; }
internal string DebuggerDisplay
{
get
{
return String.Format(CultureInfo.InvariantCulture, "Number: {0} State: {1}", Number, State);
}
}
public IssueUpdate ToUpdate()
{
var milestoneId = Milestone == null
? new int?()
: Milestone.Number;
var assignee = Assignee == null
? null
: Assignee.Login;
var issueUpdate = new IssueUpdate
{
Assignee = assignee,
Body = Body,
Milestone = milestoneId,
State = State,
Title = Title
};
foreach (var label in Labels.Select(l => l.Name))
{
issueUpdate.Labels.Add(label);
}
return issueUpdate;
}
}
}