Spaces:
Running
Running
File size: 2,389 Bytes
c7beb09 8c88a89 c7beb09 4671199 c7beb09 8c88a89 c7beb09 8c88a89 c7beb09 8c88a89 c7beb09 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using TaskTrackingSystem.Shared.Enums;
using TaskTrackingSystem.Shared.Localization;
using AppTaskStatus = TaskTrackingSystem.Shared.Enums.AppTaskStatus;
namespace TaskTrackingSystem.Shared.Models.Issue
{
public class CreateIssueDto : IValidatableObject
{
[Required]
[Range(1, long.MaxValue)]
public long TaskId { get; set; }
[Required, MaxLength(200)]
public string Title { get; set; } = string.Empty;
[MaxLength(1000)]
public string? Description { get; set; }
[Range(0, long.MaxValue)]
public long? AssignedTo { get; set; }
[Range(typeof(decimal), "0", "100000")]
public decimal? EstimatedHours { get; set; }
[Range(typeof(decimal), "0", "100000")]
public decimal? ActualHours { get; set; }
[MaxLength(300)]
public string? DelayReason { get; set; }
public bool IsBlocked { get; set; }
[MaxLength(200)]
public string? BlockedBy { get; set; }
[Range(0, 3)]
public int EscalationLevel { get; set; }
[Required]
public DateTime StartDate { get; set; }
[Required]
public DateTime DueDate { get; set; }
[EnumDataType(typeof(AppTaskStatus))]
public AppTaskStatus StatusId { get; set; }
[EnumDataType(typeof(TaskPriority))]
public TaskPriority PriorityId { get; set; }
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
{
if (StartDate == default)
{
yield return new ValidationResult(AppLocalization.Text("validation.startDateRequired", "Start date is required."), new[] { nameof(StartDate) });
}
if (DueDate == default)
{
yield return new ValidationResult(AppLocalization.Text("validation.dueDateRequired", "Due date is required."), new[] { nameof(DueDate) });
}
if (StartDate != default && DueDate != default && DueDate.Date < StartDate.Date)
{
yield return new ValidationResult(AppLocalization.Text("validation.dueDateBeforeStart", "Due date cannot be earlier than start date."), new[] { nameof(DueDate), nameof(StartDate) });
}
}
}
}
|