system-praktyk-api/src/InternshipSystem.Api/Queries/EditionForm.cs
maxchil d612e74e13 ReportFields (#89)
XD

XD

XD

fix

rest

merge

 XD

XD

Co-authored-by: Michal Bohdanowicz <m.w.bohdanowicz@gmail.com>
2021-01-10 18:31:28 +01:00

40 lines
1.5 KiB
C#

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<long> AvailableSubjectsIds { get; set; } = new List<long>();
public List<long> AvailableInternshipTypesIds { get; set; } = new List<long>();
public List<long> ReportSchema { 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);
}
}
}
}