CEL_Payroll/Payroll.BO/Attendence/OutsideDuty.cs

169 lines
4.0 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.Caching;
using Ease.CoreV35.Model;
namespace Payroll.BO
{
#region OutsideDuty
[Serializable]
public class OutsideDuty : BasicBaseObject
{
#region Cache Store
private static Cache _cache = new Cache(typeof(OutsideDuty));
#endregion
#region Constructor
public OutsideDuty()
{
_name = string.Empty;
_status = EnumStatus.Active;
}
#region Input validator
public string[] InputValidator()
{
string[] sErrorString = new string[2];
if (this.Name == "")
{
sErrorString[0] = "Name can not be empty";
sErrorString[1] = "Name";
return sErrorString;
}
sErrorString = null;
return sErrorString;
}
#endregion
#endregion
#region Properties
#region Name : string
private string _name;
public string Name
{
get { return _name; }
set
{
_name = value;
}
}
#endregion
#region Service Factory IOutsideDutyService : IOutsideDutyService
internal static IOutsideDutyService Service
{
get { return Services.Factory.CreateService<IOutsideDutyService>(typeof(IOutsideDutyService)); }
}
#endregion
#endregion
#region Functions
public static OutsideDuty Get(ID nID)
{
OutsideDuty oOutsideDuty = null;
#region Cache Header
oOutsideDuty = (OutsideDuty)_cache["Get", nID];
if (oOutsideDuty != null)
return oOutsideDuty;
#endregion
oOutsideDuty = OutsideDuty.Service.Get(nID);
#region Cache Footer
_cache.Add(oOutsideDuty, "Get", nID);
#endregion
return oOutsideDuty;
}
public static ObjectsTemplate<OutsideDuty> Get()
{
#region Cache Header
ObjectsTemplate<OutsideDuty> outsideDutys = _cache["Get"] as ObjectsTemplate<OutsideDuty>;
if (outsideDutys != null)
return outsideDutys;
#endregion
try
{
outsideDutys = Service.Get();
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(outsideDutys, "Get");
#endregion
return outsideDutys;
}
public static ObjectsTemplate<OutsideDuty> Get(EnumStatus status)
{
#region Cache Header
ObjectsTemplate<OutsideDuty> oOutsideDuty = _cache["Get", status] as ObjectsTemplate<OutsideDuty>;
if (oOutsideDuty != null)
return oOutsideDuty;
#endregion
try
{
oOutsideDuty = Service.Get(status);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(oOutsideDuty, "Get", status);
#endregion
return oOutsideDuty;
}
public ID Save()
{
if (this.IsNew)
{
this.Status = EnumStatus.Active;
}
this.SetAuditTrailProperties();
return OutsideDuty.Service.Save(this);
}
public void Delete(ID id)
{
OutsideDuty.Service.Delete(id);
}
#endregion
}
#endregion
#region IOutsideDuty Service
public interface IOutsideDutyService
{
OutsideDuty Get(ID id);
ObjectsTemplate<OutsideDuty> Get();
ObjectsTemplate<OutsideDuty> Get(EnumStatus status);
ID Save(OutsideDuty item);
void Delete(ID id);
}
#endregion
}