init
This commit is contained in:
commit
e124a47765
19374 changed files with 9806149 additions and 0 deletions
|
@ -0,0 +1,19 @@
|
|||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Kreta.BusinessLogic.Classes.MobileApi.Naplo.V2.Co.Enum
|
||||
{
|
||||
public enum ErtekelesErtekFajta
|
||||
{
|
||||
None,
|
||||
[Display(Name = "Elégtelen (1) és Jeles (5) között az öt alapértelmezett érték")]
|
||||
Osztalyzat = 1,
|
||||
[Display(Name = "Szöveges értékelés")]
|
||||
Szoveges = 2,
|
||||
[Display(Name = "Százalékos értékelés")]
|
||||
Szazalekos = 3,
|
||||
[Display(Name = "Rossz, Változó, Jó, Példás")]
|
||||
MagatartasErtek = 4,
|
||||
[Display(Name = "Hanyag, Változó, Jó, Példás")]
|
||||
SzorgalomErtek = 5
|
||||
}
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
using System;
|
||||
using Kreta.Core.Validation.Exceptions;
|
||||
using Kreta.Core.Validation.Exceptions.Enum;
|
||||
using Kreta.Resources;
|
||||
|
||||
namespace Kreta.BusinessLogic.Classes.MobileApi.Naplo.V2.Co.Enum
|
||||
{
|
||||
public class NaploEnumCo<T> where T : struct, IConvertible
|
||||
{
|
||||
public static implicit operator NaploEnumCo<T>(int id) => new NaploEnumCo<T>(id);
|
||||
public static implicit operator NaploEnumCo<T>(T enumValue) => new NaploEnumCo<T>(Convert.ToInt32(enumValue));
|
||||
public static bool operator ==(NaploEnumCo<T> lhsWrapperCo, T rhsEnum) => lhsWrapperCo.GetEnum().Equals(rhsEnum);
|
||||
public static bool operator !=(NaploEnumCo<T> lhsWrapperCo, T rhsEnum) => !lhsWrapperCo.GetEnum().Equals(rhsEnum);
|
||||
|
||||
public string EnumTypeNameWPostFix => typeof(T).Name;
|
||||
public string EnumTypeName => EnumTypeNameWPostFix.Replace("Enum", "").Replace("enum", "");
|
||||
public bool IsGeneratedEnum => !string.IsNullOrWhiteSpace(Nev);
|
||||
|
||||
public T GetEnum()
|
||||
{
|
||||
T enumValue;
|
||||
|
||||
if (!System.Enum.TryParse<T>(Nev, out enumValue))
|
||||
{
|
||||
throw new ValidationException(ValidationErrorType.ResourceNotFound, ErrorResource.NemEngedelyezettVagyNemLetezoEnum);
|
||||
}
|
||||
|
||||
return enumValue;
|
||||
}
|
||||
public int Id { get; private set; }
|
||||
public string Nev { get; private set; }
|
||||
|
||||
public NaploEnumCo(int id)
|
||||
{
|
||||
Fill(id);
|
||||
if (!typeof(T).IsEnum)
|
||||
{
|
||||
throw new ArgumentException("T must be an enum");
|
||||
}
|
||||
}
|
||||
|
||||
private void Fill(int id)
|
||||
{
|
||||
Id = id;
|
||||
Nev = System.Enum.GetName(typeof(T), id);
|
||||
if (!typeof(T).IsEnum)
|
||||
{
|
||||
throw new ArgumentException("T must be an enum");
|
||||
}
|
||||
}
|
||||
|
||||
public NaploEnumCo(int id, string nev)
|
||||
{
|
||||
Id = id;
|
||||
Nev = nev;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Kreta.BusinessLogic.Classes.MobileApi.Naplo.V2.Co.Enum
|
||||
{
|
||||
public class NaploEnumListCo<T> where T : struct, IConvertible
|
||||
{
|
||||
private T KretaEnum { get; }
|
||||
public List<NaploEnumListItemCo> ElemLista { get; } = new List<NaploEnumListItemCo>();
|
||||
|
||||
public string EnumTypeNameWPostFix => typeof(T).Name;
|
||||
public string EnumTypeName => EnumTypeNameWPostFix.Replace("Enum", "").Replace("enum", "");
|
||||
|
||||
public NaploEnumListCo()
|
||||
{
|
||||
if (!typeof(T).IsEnum)
|
||||
throw new ArgumentException("T must be an enum");
|
||||
}
|
||||
|
||||
public void Fill(List<KeyValuePair<int, string>> idAndDescriptionList)
|
||||
{
|
||||
foreach (var idAndDescription in idAndDescriptionList)
|
||||
{
|
||||
ElemLista.Add(new NaploEnumListItemCo(idAndDescription.Key, System.Enum.GetName(typeof(T), idAndDescription.Key), idAndDescription.Value));
|
||||
}
|
||||
}
|
||||
public void Fill(int id, string description)
|
||||
{
|
||||
ElemLista.Add(new NaploEnumListItemCo(id, System.Enum.GetName(typeof(T), id), description));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
namespace Kreta.BusinessLogic.Classes.MobileApi.Naplo.V2.Co.Enum
|
||||
{
|
||||
public class NaploEnumListItemCo
|
||||
{
|
||||
public int Id { get; }
|
||||
public string Name { get; }
|
||||
public string Description { get; }
|
||||
|
||||
public NaploEnumListItemCo(int Id, string name, string description)
|
||||
{
|
||||
this.Id = Id;
|
||||
this.Name = name;
|
||||
this.Description = description;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue