32 lines
1.3 KiB
C#
32 lines
1.3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using System.Linq;
|
|
using Kreta.Naplo.Domain.V3.Interfaces;
|
|
|
|
namespace Kreta.Naplo.Domain.V3.HaziFeladat
|
|
{
|
|
public class HaziFeladatCreateRequest : IValidatableObject, IModelValidacio<HaziFeladatCreateRequest>
|
|
{
|
|
public string Szoveg { get; set; }
|
|
|
|
public DateTime BeadasiHatarido { get; set; }
|
|
|
|
public DateTime OraDatum { get; set; }
|
|
|
|
public int? Oraszam { get; set; }
|
|
|
|
public int TantargyId { get; set; }
|
|
|
|
public int OsztalyCsoportId { get; set; }
|
|
|
|
public Dictionary<Predicate<HaziFeladatCreateRequest>, string> ModelValidaciok => new Dictionary<Predicate<HaziFeladatCreateRequest>, string>
|
|
{
|
|
{ x => string.IsNullOrWhiteSpace(x.Szoveg), "Házi feladat szövege nem lehet üres!" },
|
|
{ x => x.BeadasiHatarido < DateTime.Today.AddDays(1), "Házi feladat nem rögzíthető korábbi határidővel, mint a holnapi!" },
|
|
{ x => x.BeadasiHatarido < x.OraDatum, "Házi feladat határideje nem lehet korábban, mint az óra dátuma!" }
|
|
};
|
|
|
|
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext) => ModelValidaciok.Where(x => x.Key.Invoke(this)).AsEnumerable().Select(x => new ValidationResult(x.Value));
|
|
}
|
|
}
|