File size: 1,015 Bytes
3418204
 
 
 
 
 
bec15e2
3418204
 
 
 
bec15e2
3418204
 
 
 
 
 
 
 
 
 
3bd1468
bec15e2
3bd1468
bec15e2
 
 
 
 
 
 
 
 
 
3418204
 
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
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;

namespace TaskTrackingSystem.Shared.Models.Project
{
    public class CreateProjectDto : IValidatableObject
    {
        [Required, MaxLength(150)]
        public string Name { get; set; } = string.Empty;

        [MaxLength(500)]
        public string? Description { 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 (EndDate < StartDate)
            {
                yield return new ValidationResult(
                    "End date cannot be before start date.",
                    new[] { nameof(EndDate), nameof(StartDate) });
            }
        }
    }
}