init
This commit is contained in:
commit
e124a47765
19374 changed files with 9806149 additions and 0 deletions
|
@ -0,0 +1,11 @@
|
|||
using Kreta.BusinessLogic.Classes.MobileApi.Naplo.V2.Co.Enum;
|
||||
using Kreta.Enums;
|
||||
|
||||
namespace Kreta.BusinessLogic.Classes.MobileApi.Naplo.V2.Co.Post.Naplozas
|
||||
{
|
||||
public class MulasztasForOraNaplozasRequestCo
|
||||
{
|
||||
public NaploEnumCo<MulasztasTipusEnum> Tipus { get; set; }
|
||||
public int? Keses { get; set; }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,126 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Kreta.BusinessLogic.Logic.Naplozas;
|
||||
using Kreta.Enums;
|
||||
using Kreta.Resources;
|
||||
|
||||
namespace Kreta.BusinessLogic.Classes.MobileApi.Naplo.V2.Co.Post.Naplozas
|
||||
{
|
||||
public class OraNaplozasRequestCo : IValidatableObject
|
||||
{
|
||||
public DateTime Datum { get; set; }
|
||||
|
||||
public string Hazifeladat { get; set; }
|
||||
|
||||
public DateTime? HazifeladatHatarido { get; set; }
|
||||
|
||||
public int? HazifeladatId { get; set; }
|
||||
|
||||
public bool IsElmaradt { get; set; }
|
||||
|
||||
public int MobilId { get; set; }
|
||||
|
||||
public int? OrarendiOraId { get; set; }
|
||||
|
||||
public DateTime RogzitesDatum { get; set; }
|
||||
|
||||
public int? TanitasiOraId { get; set; }
|
||||
|
||||
public List<TanuloForOraNaplozasRequestCo> TanuloLista { get; set; }
|
||||
|
||||
public string Tema { get; set; }
|
||||
|
||||
public int? CsatolmanyId { get; set; }
|
||||
|
||||
public void ConvertTo(NaplozasMobilCo co)
|
||||
{
|
||||
co.OraAdat.Datum = Datum;
|
||||
co.OraAdat.IsElmaradt = IsElmaradt;
|
||||
co.OraAdat.Tema = Tema;
|
||||
co.OraAdat.OrarendiOraId = OrarendiOraId;
|
||||
co.OraAdat.TanitasiOraId = TanitasiOraId;
|
||||
co.Hazifeladat.Id = HazifeladatId;
|
||||
co.Hazifeladat.Szoveg = Hazifeladat;
|
||||
co.Hazifeladat.Hatarido = HazifeladatHatarido;
|
||||
co.Hazifeladat.CsatolmanyId = CsatolmanyId;
|
||||
co.OraAdat.RogzitesDatuma = RogzitesDatum;
|
||||
foreach (var tanulo in TanuloLista)
|
||||
{
|
||||
var tanuloMulasztas = new NaplozasMobilCo.MulasztasModel
|
||||
{
|
||||
TanuloId = tanulo.Id,
|
||||
MulasztasTipus = tanulo.Mulasztas.Tipus.Id,
|
||||
Keses = tanulo.Mulasztas.Keses
|
||||
};
|
||||
|
||||
foreach (var feljegyzesTipus in tanulo.FeljegyzesTipusLista)
|
||||
{
|
||||
switch (feljegyzesTipus.Id)
|
||||
{
|
||||
case (int)EsemenyTipusEnum.HaziFeladatHiany:
|
||||
tanuloMulasztas.HazifeladatHiany = true;
|
||||
break;
|
||||
case (int)EsemenyTipusEnum.Felszereleshiany:
|
||||
tanuloMulasztas.FelszerelesHiany = true;
|
||||
break;
|
||||
case (int)EsemenyTipusEnum.Dicseret:
|
||||
tanuloMulasztas.TanoraiDicseret = true;
|
||||
break;
|
||||
case (int)EsemenyTipusEnum.SzakmaiMentessegNemHivatalos:
|
||||
tanuloMulasztas.Felmentes = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
co.MulasztasList.Add(tanuloMulasztas);
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
|
||||
{
|
||||
if (HazifeladatHatarido < Datum.Date.AddDays(1))
|
||||
{
|
||||
yield return new ValidationResult(ErrorResource.HazifeladatNemrogzithetoHataridoKorabbiMintAzOraDatuma);
|
||||
}
|
||||
|
||||
if (HazifeladatHatarido < DateTime.Today.AddDays(1))
|
||||
{
|
||||
yield return new ValidationResult(ErrorResource.HazifeladatNemrogzithetoHataridoKorabbiMintAHolnapiNap);
|
||||
}
|
||||
|
||||
if (HazifeladatId.HasValue && string.IsNullOrWhiteSpace(Hazifeladat))
|
||||
{
|
||||
yield return new ValidationResult(OrarendResource.HazifeladatSzovegKotelezo);
|
||||
}
|
||||
|
||||
var occurrenceNumberByPrimaryKey = new Dictionary<int, int>();
|
||||
|
||||
foreach (var tanulo in TanuloLista)
|
||||
{
|
||||
if (occurrenceNumberByPrimaryKey.ContainsKey(tanulo.Id))
|
||||
{
|
||||
occurrenceNumberByPrimaryKey[tanulo.Id]++;
|
||||
}
|
||||
else
|
||||
{
|
||||
occurrenceNumberByPrimaryKey.Add(tanulo.Id, 1);
|
||||
}
|
||||
|
||||
//TODO: késés értékének felső határát is validálni (nagyobb átalakítás)
|
||||
if (tanulo.Mulasztas.Tipus.Id == (int)MulasztasTipusEnum.keses && tanulo.Mulasztas.Keses <= 0)
|
||||
{
|
||||
yield return new ValidationResult(string.Format(ErrorResource.AKesesErtekeNemLehet0, tanulo.Mulasztas.Keses));
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var occurrenceNumberByPrimaryKeyItem in occurrenceNumberByPrimaryKey)
|
||||
{
|
||||
if (occurrenceNumberByPrimaryKeyItem.Value > 1)
|
||||
{
|
||||
yield return new ValidationResult($"A tanuló többször szerepel: {nameof(TanuloForOraNaplozasRequestCo.Id)}={occurrenceNumberByPrimaryKeyItem.Key}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
using Kreta.Core.Validation.Exceptions;
|
||||
|
||||
namespace Kreta.BusinessLogic.Classes.MobileApi.Naplo.V2.Co.Post.Naplozas
|
||||
{
|
||||
public class OraNaplozasResponseCo
|
||||
{
|
||||
public int MobilId { get; set; }
|
||||
public ValidationException Exception { get; set; }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
using System.Collections.Generic;
|
||||
using Kreta.BusinessLogic.Classes.MobileApi.Naplo.V2.Co.Enum;
|
||||
using Kreta.Enums.ManualEnums;
|
||||
|
||||
namespace Kreta.BusinessLogic.Classes.MobileApi.Naplo.V2.Co.Post.Naplozas
|
||||
{
|
||||
public class TanuloForOraNaplozasRequestCo
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public MulasztasForOraNaplozasRequestCo Mulasztas { get; set; }
|
||||
public List<NaploEnumCo<FeljegyzesTipusEnum>> FeljegyzesTipusLista { get; set; }
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue