using System.ComponentModel.DataAnnotations;
namespace Lagerbestand.Models;
///
/// Priority levels for Kanban tasks
///
public enum KanbanTaskPriority
{
Low = 0,
Medium = 1,
High = 2,
Urgent = 3
}
///
/// Represents a task/card in the Kanban board
///
public class KanbanTask
{
public Guid Id { get; set; } = Guid.NewGuid();
[Required]
[MaxLength(200)]
public string Title { get; set; } = string.Empty;
///
/// Rich text description of the task
///
public string? Description { get; set; }
///
/// The column this task belongs to
///
public Guid ColumnId { get; set; }
///
/// Sort order within the column
///
public int SortOrder { get; set; }
///
/// Due date for the task
///
public DateTime? DueDate { get; set; }
///
/// Priority level
///
public KanbanTaskPriority Priority { get; set; } = KanbanTaskPriority.Medium;
///
/// Estimated time in minutes
///
public int? EstimatedMinutes { get; set; }
///
/// User who created the task
///
public Guid? CreatedByUserId { get; set; }
///
/// Whether the task is archived
///
public bool IsArchived { get; set; }
///
/// When the task was moved to a completed column
///
public DateTime? CompletedAt { get; set; }
///
/// When the task was archived
///
public DateTime? ArchivedAt { get; set; }
///
/// Simple notes/memo field for the task
///
public string? NotesText { get; set; }
///
/// Free text field for tire size notes (Reifengröße)
///
public string? TireSizeNote { get; set; }
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
public DateTime UpdatedAt { get; set; } = DateTime.UtcNow;
// Navigation properties
public virtual KanbanColumn? Column { get; set; }
public virtual AppUser? CreatedByUser { get; set; }
public virtual ICollection Todos { get; set; } = new List();
public virtual ICollection TaskLabels { get; set; } = new List();
public virtual ICollection Comments { get; set; } = new List();
public virtual ICollection Notes { get; set; } = new List();
public virtual ICollection Attachments { get; set; } = new List();
public virtual ICollection Assignees { get; set; } = new List();
public virtual ICollection TaskCustomers { get; set; } = new List();
public virtual ICollection TaskTireStacks { get; set; } = new List();
// Computed properties
public bool IsDueToday => DueDate.HasValue && DueDate.Value.Date == DateTime.UtcNow.Date && !CompletedAt.HasValue;
public bool IsOverdue => DueDate.HasValue && DueDate.Value.Date < DateTime.UtcNow.Date && !IsArchived && !CompletedAt.HasValue;
public int TodosCompleted => Todos.Count(t => t.IsCompleted);
public int TodosTotal => Todos.Count;
public string TodoProgress => TodosTotal > 0 ? $"{TodosCompleted}/{TodosTotal}" : "";
public string PriorityText => Priority switch
{
KanbanTaskPriority.Low => "Niedrig",
KanbanTaskPriority.Medium => "Mittel",
KanbanTaskPriority.High => "Hoch",
KanbanTaskPriority.Urgent => "Dringend",
_ => "Mittel"
};
public string PriorityIcon => Priority switch
{
KanbanTaskPriority.Low => "⬇️",
KanbanTaskPriority.Medium => "➡️",
KanbanTaskPriority.High => "⬆️",
KanbanTaskPriority.Urgent => "🔥",
_ => "➡️"
};
public string EstimatedTimeDisplay
{
get
{
if (!EstimatedMinutes.HasValue) return "";
var hours = EstimatedMinutes.Value / 60;
var mins = EstimatedMinutes.Value % 60;
if (hours > 0 && mins > 0) return $"{hours}h {mins}m";
if (hours > 0) return $"{hours}h";
return $"{mins}m";
}
}
}