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 Religion [Serializable] public class Religion : BasicBaseObject { #region Cache Store private static Cache _cache = new Cache(typeof(Religion)); #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.Name == "") { sErrorString[0] = "Description can not be empty"; sErrorString[1] = "Description"; return sErrorString; } sErrorString = null; return sErrorString; } #endregion public Religion() { _code = string.Empty; _name = string.Empty; _status = EnumStatus.Active; } #endregion #region Properties #region code : string private string _code; public string Code { get { return _code; } set { base.OnPropertyChange("code", _code, value); _code = value; } } #endregion #region name : string private string _name; public string Name { get { return _name; } set { base.OnPropertyChange("name", _name, value); _name = value; } } #endregion #region Service Factory IReligionService : IReligionService internal static IReligionService Service { get { return Services.Factory.CreateService(typeof(IReligionService)); } } #endregion #endregion #region Functions public string GetNextCode() { return Religion.Service.GetNextCode(); } public static Religion Get(ID nID) { Religion oReligion = null; #region Cache Header oReligion = (Religion)_cache["Get", nID]; if (oReligion != null) return oReligion; #endregion oReligion = Religion.Service.Get(nID); #region Cache Footer _cache.Add(oReligion, "Get", nID); #endregion return oReligion; } public static Religion Get(string sCode) { Religion oReligion = null; #region Cache Header oReligion = (Religion)_cache["Get", sCode]; if (oReligion != null) return oReligion; #endregion oReligion = Religion.Service.Get(sCode); #region Cache Footer _cache.Add(oReligion, "Get", sCode); #endregion return oReligion; } public static ObjectsTemplate Get() { #region cache header ObjectsTemplate religions = _cache["Get"] as ObjectsTemplate; if (religions != null) return religions; #endregion try { religions = Service.Get(); } catch (ServiceException e) { throw new Exception(e.Message, e); } #region cache footer _cache.Add(religions, "Get"); #endregion return religions; } public static ObjectsTemplate Get(EnumStatus status) { #region Cache Header ObjectsTemplate religions = _cache["Get",status] as ObjectsTemplate; if (religions != null) return religions; #endregion try { religions = Service.Get(status); } catch (ServiceException e) { throw new Exception(e.Message, e); } #region Cache Footer _cache.Add(religions, "Get",status); #endregion return religions; } public ID Save() { this.SetAuditTrailProperties(); return Religion.Service.Save(this); } public void Delete(ID id) { Religion.Service.Delete(id); } #endregion } #endregion #region IReligion Service public interface IReligionService { Religion Get(ID id); ObjectsTemplate Get(); ObjectsTemplate Get(EnumStatus status); ID Save(Religion item); void Delete(ID id); Religion Get(string sCode); string GetNextCode(); } #endregion }