init
This commit is contained in:
commit
e124a47765
19374 changed files with 9806149 additions and 0 deletions
|
@ -0,0 +1,16 @@
|
|||
namespace Kreta.Ellenorzo.Domain.VN.Common
|
||||
{
|
||||
public class ApiSecurity
|
||||
{
|
||||
public ApiSecurity(string accessTokenRaw, string securityKey)
|
||||
{
|
||||
AccessTokenRaw = accessTokenRaw;
|
||||
SecurityKey = securityKey;
|
||||
Signature = AccessTokenRaw.Split('.')[2];
|
||||
}
|
||||
|
||||
public string AccessTokenRaw { get; private set; }
|
||||
public string SecurityKey { get; private set; }
|
||||
public string Signature { get; private set; }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Kreta.Ellenorzo.Enums.VN;
|
||||
|
||||
namespace Kreta.Ellenorzo.Domain.VN.Common
|
||||
{
|
||||
public class DateTimeIntervalRequest : IValidatableObject
|
||||
{
|
||||
private DateTime? _toDate;
|
||||
|
||||
public DateTimeIntervalRequest(DefaultInterval defaultInterval)
|
||||
{
|
||||
switch (defaultInterval)
|
||||
{
|
||||
case DefaultInterval.AktivTanev:
|
||||
FromDate = null;
|
||||
_toDate = null;
|
||||
break;
|
||||
case DefaultInterval.None:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public DateTimeIntervalRequest(DefaultInterval defaultInterval, DateTime? fromDate, DateTime? toDate) : this(defaultInterval)
|
||||
{
|
||||
if (fromDate.HasValue || toDate.HasValue)
|
||||
{
|
||||
FromDate = fromDate;
|
||||
ToDate = toDate;
|
||||
}
|
||||
}
|
||||
|
||||
public DateTime? FromDate { get; private set; }
|
||||
|
||||
public DateTime? ToDate { get => _toDate?.Date.AddDays(1).AddSeconds(-1); private set => _toDate = value; }
|
||||
|
||||
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
|
||||
{
|
||||
if (FromDate > ToDate)
|
||||
{
|
||||
yield return new ValidationResult("ToDateMustBeGreaterOrEqualThanFromDate");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Kreta.DataAccessManual.Interfaces;
|
||||
using Kreta.Ellenorzo.Dao.VN.Ellenorzo;
|
||||
using Kreta.Ellenorzo.Enums;
|
||||
|
||||
namespace Kreta.Ellenorzo.Domain.VN.Common
|
||||
{
|
||||
public class DefaultConnectionParameters
|
||||
{
|
||||
public string IntezmenyAzonosito { get; }
|
||||
|
||||
public int IntezmenyId { get; }
|
||||
|
||||
public int TanevId { get; }
|
||||
|
||||
public int TanevSorszam { get; }
|
||||
|
||||
public int FelhasznaloId { get; }
|
||||
|
||||
public int TanuloId { get; }
|
||||
|
||||
public int? GondviseloId { get; }
|
||||
|
||||
public IEnumerable<FelhasznaloSzerepkor> JogosultsagLista { get; }
|
||||
|
||||
public IDalHandler DalHandler { get; set; }
|
||||
|
||||
public string UserName { get; }
|
||||
|
||||
public Guid UserIdpUniqueId { get; }
|
||||
|
||||
public Guid StudentIdpUniqueId { get; }
|
||||
|
||||
public Guid InstituteUniqueId { get; }
|
||||
|
||||
public DefaultConnectionParameters(MobileUser mobileUser, IntezmenyAdatokDao intezmenyAdatok, string intezmenyAzonosito)
|
||||
{
|
||||
IntezmenyAzonosito = intezmenyAzonosito;
|
||||
TanuloId = mobileUser.UserId;
|
||||
GondviseloId = mobileUser.TutelaryId;
|
||||
FelhasznaloId = GondviseloId ?? TanuloId;
|
||||
JogosultsagLista = mobileUser.Roles;
|
||||
UserName = mobileUser.UserName;
|
||||
UserIdpUniqueId = mobileUser.UserIdpUniqueId;
|
||||
StudentIdpUniqueId = mobileUser.StudentIdpUniqueId;
|
||||
TanevId = intezmenyAdatok.TanevId;
|
||||
TanevSorszam = intezmenyAdatok.TanevSorszam;
|
||||
IntezmenyId = intezmenyAdatok.IntezmenyId;
|
||||
InstituteUniqueId = mobileUser.InstituteUniqueId;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
using System.Collections.Generic;
|
||||
using Kreta.Ellenorzo.Domain.VN.UniqueIdentifier;
|
||||
|
||||
namespace Kreta.Ellenorzo.Domain.VN.Common
|
||||
{
|
||||
public class IntezmenyModel : IEqualityComparer<IntezmenyModel>
|
||||
{
|
||||
public IntezmenyUid Uid { get; set; }
|
||||
|
||||
public string Azonosito { get; set; }
|
||||
|
||||
public string TeljesNev { get; set; }
|
||||
|
||||
public bool Equals(IntezmenyModel x, IntezmenyModel y) => x.Uid.Equals(x.Uid, y.Uid);
|
||||
|
||||
public int GetHashCode(IntezmenyModel obj) => obj.Uid.UidRaw.GetHashCode();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,100 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Kreta.Ellenorzo.Enums;
|
||||
|
||||
namespace Kreta.Ellenorzo.Domain.VN.Common
|
||||
{
|
||||
public class MobileUser
|
||||
{
|
||||
private const int MinimumIdentifierValue = 1;
|
||||
|
||||
public MobileUser(string instituteCode, int userId, string userName, int? tutelaryId, IEnumerable<FelhasznaloSzerepkor> roles, int schoolYearId, ApiSecurity apiSecurity, Guid userIdpUniqueId, Guid studentIdpUniqueId, Guid instituteUniqueId)
|
||||
{
|
||||
ApiSecurity = apiSecurity;
|
||||
|
||||
if (string.IsNullOrWhiteSpace(instituteCode))
|
||||
{
|
||||
throw new ArgumentException($"{nameof(instituteCode)} cannot be null or whitespace");
|
||||
}
|
||||
|
||||
InstituteCode = instituteCode;
|
||||
|
||||
if (userId < MinimumIdentifierValue)
|
||||
{
|
||||
throw new ArgumentException($"{nameof(userId)} must be greater or equal to {MinimumIdentifierValue}");
|
||||
}
|
||||
|
||||
UserId = userId;
|
||||
|
||||
if (string.IsNullOrWhiteSpace(userName))
|
||||
{
|
||||
throw new ArgumentException($"{nameof(userName)} cannot be null or whitespace");
|
||||
}
|
||||
|
||||
UserName = userName;
|
||||
|
||||
if (roles == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(roles));
|
||||
}
|
||||
|
||||
if (!roles.Any())
|
||||
{
|
||||
throw new ArgumentException($"User \"{instituteCode}/{userId}\" must have at least one role");
|
||||
}
|
||||
|
||||
Roles = roles;
|
||||
|
||||
if (tutelaryId != null)
|
||||
{
|
||||
if (tutelaryId < MinimumIdentifierValue)
|
||||
{
|
||||
throw new ArgumentException($"{nameof(tutelaryId)} must be greater or equal to {MinimumIdentifierValue}");
|
||||
}
|
||||
|
||||
if (!roles.Contains(FelhasznaloSzerepkor.Gondviselo))
|
||||
{
|
||||
throw new ArgumentException($"{nameof(roles)} must contain {FelhasznaloSzerepkor.Gondviselo} because {nameof(tutelaryId)} is not null");
|
||||
}
|
||||
}
|
||||
|
||||
TutelaryId = tutelaryId;
|
||||
|
||||
if (schoolYearId < MinimumIdentifierValue)
|
||||
{
|
||||
throw new ArgumentException($"{nameof(schoolYearId)} must be greater or equal to {MinimumIdentifierValue}");
|
||||
}
|
||||
|
||||
SchoolYearId = schoolYearId;
|
||||
|
||||
UserIdpUniqueId = userIdpUniqueId;
|
||||
|
||||
StudentIdpUniqueId = studentIdpUniqueId;
|
||||
|
||||
InstituteUniqueId = instituteUniqueId;
|
||||
}
|
||||
|
||||
public int ActualUserId => TutelaryId ?? UserId;
|
||||
|
||||
public string InstituteCode { get; }
|
||||
|
||||
public ApiSecurity ApiSecurity { get; }
|
||||
|
||||
public int SchoolYearId { get; }
|
||||
|
||||
public IEnumerable<FelhasznaloSzerepkor> Roles { get; }
|
||||
|
||||
public int? TutelaryId { get; }
|
||||
|
||||
public int UserId { get; }
|
||||
|
||||
public string UserName { get; }
|
||||
|
||||
public Guid UserIdpUniqueId { get; }
|
||||
|
||||
public Guid StudentIdpUniqueId { get; }
|
||||
|
||||
public Guid InstituteUniqueId { get; }
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue