Spaces:
Runtime error
Runtime error
File size: 1,400 Bytes
3dd5c9a | 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 | using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
namespace TaskTrackingSystem.Shared.Models.Project
{
public class CreateProjectDto : IValidatableObject
{
[MaxLength(150)]
public string Name { get; set; } = string.Empty;
[MaxLength(150)]
public string? NameMy { get; set; }
[MaxLength(500)]
public string? Description { get; set; }
[MaxLength(500)]
public string? DescriptionMy { get; set; }
[Required]
public DateTime StartDate { get; set; }
[Required]
public DateTime EndDate { get; set; }
[Required]
public long CreatedById { get; set; }
[Range(0, 100000)]
public int? BudgetedHours { get; set; }
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
{
if (string.IsNullOrWhiteSpace(Name) && string.IsNullOrWhiteSpace(NameMy))
{
yield return new ValidationResult("At least one project name is required.", new[] { nameof(Name), nameof(NameMy) });
}
if (EndDate < StartDate)
{
yield return new ValidationResult(
"End date cannot be before start date.",
new[] { nameof(EndDate), nameof(StartDate) });
}
}
}
}
|