CEL_Payroll/Payroll.BO/HRBasic/Hobby.cs

204 lines
4.9 KiB
C#
Raw 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 Hobby
[Serializable]
public class Hobby : BasicBaseObject
{
#region Cache Store
private static Cache _cache = new Cache(typeof(Hobby));
#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 Hobby()
{
_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 IHobbyService : IHobbyService
internal static IHobbyService Service
{
get { return Services.Factory.CreateService<IHobbyService>(typeof(IHobbyService)); }
}
#endregion
#endregion
#region Function
public static Hobby Get(ID nID)
{
Hobby oHobby = null;
#region Cache Header
oHobby = (Hobby)_cache["Get", nID];
if (oHobby != null)
return oHobby;
#endregion
oHobby = Hobby.Service.Get(nID);
#region Cache Footer
_cache.Add(oHobby, "Get", nID);
#endregion
return oHobby;
}
public static Hobby Get(string sCode)
{
Hobby oHobby = null;
#region Cache Header
oHobby = (Hobby)_cache["Get", sCode];
if (oHobby != null)
return oHobby;
#endregion
oHobby = Hobby.Service.Get(sCode);
#region Cache Footer
_cache.Add(oHobby, "Get", sCode);
#endregion
return oHobby;
}
public static ObjectsTemplate<Hobby> Get()
{
#region cache header
ObjectsTemplate<Hobby> hobbies = _cache["Get"] as ObjectsTemplate<Hobby>;
if (hobbies != null)
return hobbies;
#endregion
try
{
hobbies = Service.Get();
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region cache footer
_cache.Add(hobbies, "Get");
#endregion
return hobbies;
}
public static ObjectsTemplate<Hobby> Get(EnumStatus status)
{
#region Cache Header
ObjectsTemplate<Hobby> hobbies = _cache["Get", status] as ObjectsTemplate<Hobby>;
if (hobbies != null)
return hobbies;
#endregion
try
{
hobbies = Service.Get(status);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(hobbies, "Get", status);
#endregion
return hobbies;
}
public ID Save()
{
this.SetAuditTrailProperties();
return Hobby.Service.Save(this);
}
public void Delete(ID id)
{
Hobby.Service.Delete(id);
}
#endregion
}
#endregion
#region IHobby Service
public interface IHobbyService
{
Hobby Get(ID id);
Hobby Get(string sCode);
ObjectsTemplate<Hobby> Get();
ObjectsTemplate<Hobby> Get(EnumStatus status);
ID Save(Hobby item);
void Delete(ID id);
}
#endregion
}