42 lines
1.1 KiB
C#
42 lines
1.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel.DataAnnotations;
|
|
|
|
namespace LCU.Shared.Collections.RepoApiLib.Hosted
|
|
{
|
|
public class TaskSettings : IValidatableObject
|
|
{
|
|
[Required]
|
|
public DateTime StartDate { get; set; }
|
|
|
|
[Required]
|
|
public DateTime EndDate { get; set; }
|
|
|
|
public string TaskUser { get; set; }
|
|
|
|
[Required]
|
|
[MaxLength(25)]
|
|
[MinLength(3)]
|
|
public string QueueRoute { get; set; }
|
|
|
|
public const string SystemUser = "System";
|
|
|
|
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
|
|
{
|
|
var results = new List<ValidationResult>();
|
|
|
|
if (StartDate.Date > DateTime.Today)
|
|
{
|
|
results.Add(new ValidationResult("StartDate cannot be in future", new[] { "StartDate" }));
|
|
}
|
|
|
|
if (EndDate.Date < StartDate.Date)
|
|
{
|
|
results.Add(new ValidationResult("EndDate cannot be before StartDate", new[] { "EndDate" }));
|
|
}
|
|
|
|
return results;
|
|
}
|
|
}
|
|
}
|