Files
Blueberry/Blueberry.Redmine/Dto/IssueList.cs
2025-12-15 09:26:27 +01:00

184 lines
5.4 KiB
C#

#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring as nullable.
using System.Text.Json.Serialization;
namespace Blueberry.Redmine.Dto
{
public class IssueList
{
public class AssignedTo
{
[JsonPropertyName("id")]
public int Id { get; set; }
[JsonPropertyName("name")]
public string Name { get; set; }
}
public class Author
{
[JsonPropertyName("id")]
public int Id { get; set; }
[JsonPropertyName("name")]
public string Name { get; set; }
}
public class CustomField
{
[JsonPropertyName("id")]
public int Id { get; set; }
[JsonPropertyName("name")]
public string Name { get; set; }
[JsonPropertyName("value")]
public string Value { get; set; }
}
public class Issue
{
[JsonPropertyName("id")]
public int Id { get; set; }
[JsonPropertyName("project")]
public Project Project { get; set; }
public string ProjectName => Project.Name;
[JsonPropertyName("tracker")]
public Tracker Tracker { get; set; }
[JsonPropertyName("status")]
public Status Status { get; set; }
public string StatusName => Status.Name;
[JsonPropertyName("priority")]
public Priority Priority { get; set; }
public string PriorityName => Priority.Name;
[JsonPropertyName("author")]
public Author Author { get; set; }
[JsonPropertyName("assigned_to")]
public AssignedTo AssignedTo { get; set; }
[JsonPropertyName("subject")]
public string Subject { get; set; }
[JsonPropertyName("description")]
public string Description { get; set; }
[JsonPropertyName("start_date")]
public string StartDate { get; set; }
[JsonPropertyName("due_date")]
public string DueDate { get; set; }
[JsonPropertyName("done_ratio")]
public int DoneRatio { get; set; }
[JsonPropertyName("is_private")]
public bool IsPrivate { get; set; }
[JsonPropertyName("estimated_hours")]
public double? EstimatedHours { get; set; }
[JsonPropertyName("custom_fields")]
public List<CustomField> CustomFields { get; set; }
[JsonPropertyName("created_on")]
public DateTime CreatedOn { get; set; }
[JsonPropertyName("updated_on")]
public DateTime UpdatedOn { get; set; }
public string LastUpdate
{
get
{
var span = DateTime.Now - UpdatedOn;
if (span.TotalMinutes < 1) return "épp most";
if (span.TotalMinutes < 60) return $"{(int)span.TotalMinutes} perce";
if (span.TotalHours < 24) return $"{(int)span.TotalHours} órája";
if (span.TotalDays < 7) return $"{(int)span.TotalDays} napja";
if (span.TotalDays < 30) return $"{(int)(span.TotalDays / 7)} hete";
if (span.TotalDays < 365) return $"{(int)(span.TotalDays / 30)} hónapja";
return $"{(int)(span.TotalDays / 365)} éve";
}
}
[JsonPropertyName("closed_on")]
public DateTime? ClosedOn { get; set; }
[JsonPropertyName("parent")]
public Parent Parent { get; set; }
}
public class Parent
{
[JsonPropertyName("id")]
public int Id { get; set; }
}
public class Priority
{
[JsonPropertyName("id")]
public int Id { get; set; }
[JsonPropertyName("name")]
public string Name { get; set; }
}
public class Project
{
[JsonPropertyName("id")]
public int Id { get; set; }
[JsonPropertyName("name")]
public string Name { get; set; }
}
public class SimpleRoot
{
[JsonPropertyName("issue")]
public Issue Issue { get; set; }
}
public class Root : IResponseList
{
[JsonPropertyName("issues")]
public List<Issue> Issues { get; set; }
[JsonPropertyName("total_count")]
public int TotalCount { get; set; }
[JsonPropertyName("offset")]
public int Offset { get; set; }
[JsonPropertyName("limit")]
public int Limit { get; set; }
}
public class Status
{
[JsonPropertyName("id")]
public int Id { get; set; }
[JsonPropertyName("name")]
public string Name { get; set; }
}
public class Tracker
{
[JsonPropertyName("id")]
public int Id { get; set; }
[JsonPropertyName("name")]
public string Name { get; set; }
}
}
}
#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring as nullable.