38 lines
1.4 KiB
C#
38 lines
1.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using FluentValidation;
|
|
using InternshipSystem.Core;
|
|
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<long> AvailableSubjectsIds { get; set; } = new List<long>();
|
|
public List<long> AvailableInternshipTypesIds { get; set; } = new List<long>();
|
|
|
|
public class Validator : AbstractValidator<EditionForm>
|
|
{
|
|
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);
|
|
}
|
|
}
|
|
}
|
|
} |