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 District [Serializable] public class District : BasicBaseObject { #region Cache Store private static Cache _cache = new Cache(typeof(District)); #endregion #region constructor public District() { _code = string.Empty; _name = string.Empty; _divisionID = null; _status = EnumStatus.Active; } #endregion #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] = "Name can not be empty"; sErrorString[1] = "Name"; return sErrorString; } sErrorString = null; return sErrorString; } #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", _code, value); _name = value; } } #endregion #region divisionID : ID private ID _divisionID; public ID DivisionID { get { return _divisionID; } set { _divisionID = value; } } #endregion #region Service Factory IDistrictService : IDistrictService internal static IDistrictService Service { get { return Services.Factory.CreateService(typeof(IDistrictService)); } } #endregion #endregion #region Function public static District Get(ID nID) { District oDistrict = null; #region Cache Header oDistrict = (District)_cache["Get", nID]; if (oDistrict != null) return oDistrict; #endregion oDistrict = District.Service.Get(nID); #region Cache Footer _cache.Add(oDistrict, "Get", nID); #endregion return oDistrict; } public static District Get(string sCode) { District oDistrict = null; #region Cache Header oDistrict = (District)_cache["Get", sCode]; if (oDistrict != null) return oDistrict; #endregion oDistrict = District.Service.Get(sCode); #region Cache Footer _cache.Add(oDistrict, "Get", sCode); #endregion return oDistrict; } public static ObjectsTemplate Get() { #region cache header ObjectsTemplate districts = _cache["Get"] as ObjectsTemplate; if (districts != null) return districts; #endregion try { districts = Service.Get(); } catch (ServiceException e) { throw new Exception(e.Message, e); } #region cache footer _cache.Add(districts, "Get"); #endregion return districts; } public static ObjectsTemplate Get(EnumStatus status) { #region Cache Header ObjectsTemplate districts = _cache["Get", status] as ObjectsTemplate; if (districts != null) return districts; #endregion try { districts = Service.Get(status); } catch (ServiceException e) { throw new Exception(e.Message, e); } #region Cache Footer _cache.Add(districts, "Get", status); #endregion return districts; } public ID Save() { this.SetAuditTrailProperties(); return District.Service.Save(this); } public void Delete(ID id) { District.Service.Delete(id); } #endregion } #endregion #region IDistrict Service public interface IDistrictService { District Get(ID id); District Get(string sCode); ObjectsTemplate Get(); ObjectsTemplate Get(EnumStatus status); ID Save(District item); void Delete(ID id); } #endregion }