CEL_Payroll/Payroll.BO/HRBasic/Nationality.cs

202 lines
5.2 KiB
C#
Raw Permalink Normal View History

2024-09-17 14:30:13 +06:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Ease.CoreV35;
using Ease.CoreV35.Model;
using Ease.CoreV35.Caching;
using System.Data.Linq.Mapping;
namespace Payroll.BO
{
#region Class Nationality
[Serializable]
public class Nationality : BasicBaseObject
{
#region Cache Store
private static Cache _cache = new Cache(typeof(Nationality));
#endregion
#region Constructor
#region Input validator
public string[] InputValidator()
{
string[] sErrorString = new string[2];
if (this.Code == "")
{
sErrorString[0] = "Code can not be empty";
sErrorString[1] = "Code";
return sErrorString;
}
if (this.Description == "")
{
sErrorString[0] = "Description can not be empty";
sErrorString[1] = "Description";
return sErrorString;
}
sErrorString = null;
return sErrorString;
}
#endregion
public Nationality()
{
_code = string.Empty;
_description = string.Empty;
_status = EnumStatus.Active;
}
#endregion
#region Properties
#region code: String
private string _code;
public string Code
{
get { return _code; }
set
{
base.OnPropertyChange<string>("CODE", _code, value);
_code = value;
}
}
#endregion
#region Description: String
private string _description;
public string Description
{
get { return _description; }
set
{
base.OnPropertyChange<string>("DESCRIPTION", _description, value);
_description = value;
}
}
#endregion
#region Service Factory INationalityService : INationalityService
internal static INationalityService Service
{
get { return Services.Factory.CreateService<INationalityService>(typeof(INationalityService)); }
}
#endregion
#endregion
#region Function
public static Nationality Get(ID nID)
{
Nationality oNationality = null;
#region Cache Header
oNationality = (Nationality)_cache["Get", nID];
if (oNationality != null)
return oNationality;
#endregion
oNationality = Nationality.Service.Get(nID);
#region Cache Footer
_cache.Add(oNationality, "Get", nID);
#endregion
return oNationality;
}
public static Nationality Get(string sCode)
{
Nationality oNationality = null;
#region Cache Header
oNationality = (Nationality)_cache["Get", sCode];
if (oNationality != null)
return oNationality;
#endregion
oNationality = Nationality.Service.Get(sCode);
#region Cache Footer
_cache.Add(oNationality, "Get", sCode);
#endregion
return oNationality;
}
public static ObjectsTemplate<Nationality> Get()
{
#region cache header
ObjectsTemplate<Nationality> nationalities = _cache["Get"] as ObjectsTemplate<Nationality>;
if (nationalities != null)
return nationalities;
#endregion
try
{
nationalities = Service.Get();
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region cache footer
_cache.Add(nationalities, "Get");
#endregion
return nationalities;
}
public static ObjectsTemplate<Nationality> Get(EnumStatus status)
{
#region Cache Header
ObjectsTemplate<Nationality> nationalities = _cache["Get", status] as ObjectsTemplate<Nationality>;
if (nationalities != null)
return nationalities;
#endregion
try
{
nationalities = Service.Get(status);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(nationalities, "Get", status);
#endregion
return nationalities;
}
public ID Save()
{
this.SetAuditTrailProperties();
return Nationality.Service.Save(this);
}
public void Delete(ID id)
{
Nationality.Service.Delete(id);
}
#endregion
}
#endregion
#region INationality Service
public interface INationalityService
{
Nationality Get(ID id);
Nationality Get(string sCode);
ObjectsTemplate<Nationality> Get();
ObjectsTemplate<Nationality> Get(EnumStatus status);
ID Save(Nationality item);
void Delete(ID id);
}
#endregion
}