using System; using System.Collections.Generic; using FluentValidation; using InternshipSystem.Core; using InternshipSystem.Core.Entity; using InternshipSystem.Core.Entity.Internship; namespace InternshipSystem.Api.Queries { public class EditionForm { public Guid? Id { get; set; } public DateTime? EditionStart { get; set; } public DateTime? EditionFinish { get; set; } public DateTime? ReportingStart { get; set; } public Course Course { get; set; } public List AvailableSubjectsIds { get; set; } = new List(); public List AvailableInternshipTypesIds { get; set; } = new List(); public List ReportSchema { get; set; } = new List(); public class Validator : AbstractValidator { public Validator() { RuleFor(e => e.Id).NotNull() .When(e => !e.EditionStart.HasValue || !e.EditionFinish.HasValue || !e.ReportingStart.HasValue || e.Course == null); RuleFor(e => e.EditionStart).NotEmpty() .When(e => !e.Id.HasValue); RuleFor(e => e.EditionFinish).NotEmpty() .When(e => !e.Id.HasValue); RuleFor(e => e.ReportingStart).NotEmpty() .When(e => !e.Id.HasValue); RuleFor(e => e.Course).NotNull() .When(e => !e.Id.HasValue); } } } }