init
This commit is contained in:
commit
e124a47765
19374 changed files with 9806149 additions and 0 deletions
|
@ -0,0 +1,29 @@
|
|||
using System.Data;
|
||||
using Kreta.BusinessLogic.Helpers;
|
||||
using Kreta.Core.ConnectionType;
|
||||
using Kreta.Enums;
|
||||
|
||||
namespace Kreta.Naplo.BusinessLogic.V3.Logic
|
||||
{
|
||||
public static class HelyettesitesLogic
|
||||
{
|
||||
public class Tanar
|
||||
{
|
||||
public Tanar(int tanarId, int tanevId, int intezmenyId, string intezmenyAzonosito, OktNevelesiKategoriaEnum? oktatasNevelesKategoriaEnum = null)
|
||||
{
|
||||
TanarHelyettesiteseiDt = new HelyettesitesHelper(new MobileConnectionType(tanarId, intezmenyId, intezmenyAzonosito, tanevId))
|
||||
.GetHelyettesitesekListajaGrid(new Kreta.BusinessLogic.HelperClasses.HelyettesitesekListajaSearchCO
|
||||
{
|
||||
HelyettesitoTanarSearch = tanarId,
|
||||
FeladatKategoriaId = oktatasNevelesKategoriaEnum.HasValue ? (int)oktatasNevelesKategoriaEnum : default
|
||||
|
||||
}).Tables[0];
|
||||
}
|
||||
|
||||
private DataTable TanarHelyettesiteseiDt { get; set; }
|
||||
|
||||
public bool IsHelyettesito(int osztalyCsoportId, int tantargyId)
|
||||
=> TanarHelyettesiteseiDt.Select($"OsztalyCsoportId = {osztalyCsoportId} AND TantargyId = {tantargyId}").Length > 0;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using Kreta.Core;
|
||||
using Kreta.Core.Domain;
|
||||
using Kreta.Core.Enum;
|
||||
using Kreta.Core.Exceptions;
|
||||
|
||||
namespace Kreta.Naplo.BusinessLogic.V3.Logic
|
||||
{
|
||||
internal class ValidatorLogic
|
||||
{
|
||||
private readonly List<ValidationResult> _errorList = new List<ValidationResult>();
|
||||
|
||||
private readonly bool _isValid = true;
|
||||
|
||||
internal ValidatorLogic(object instance)
|
||||
{
|
||||
var context = new ValidationContext(instance, serviceProvider: null, items: null);
|
||||
_isValid = Validator.TryValidateObject(instance, context, _errorList, true);
|
||||
}
|
||||
|
||||
public static implicit operator string(ValidatorLogic validator) => validator.GetFirstUserFriendlyError();
|
||||
|
||||
internal BlException ConvertToValidationException()
|
||||
{
|
||||
var exception = new BlException(BlExceptionType.ModelValidacio);
|
||||
var count = 1;
|
||||
foreach (var error in _errorList)
|
||||
{
|
||||
var name = error.MemberNames.FirstOrDefault() ?? "custom_" + count;
|
||||
exception.ErrorList.Add(new DetailedErrorItem(name, error.ErrorMessage, BlExceptionType.ModelValidacio));
|
||||
count++;
|
||||
}
|
||||
|
||||
return exception;
|
||||
}
|
||||
|
||||
internal string GetFirstUserFriendlyError()
|
||||
=> _errorList.Count > 0 ? _errorList[0].ErrorMessage : string.Empty;
|
||||
|
||||
internal void ThrowExceptionIfModelIsNotvalid()
|
||||
{
|
||||
if (!_isValid)
|
||||
{
|
||||
throw ConvertToValidationException();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue