using System; using System.Collections.Generic; using System.Linq; using System.Text; using Ease.CoreV35.Caching; using Ease.CoreV35.Model; namespace Payroll.BO { #region AttnNationalHoliday [Serializable] public class AttnNationalHoliday : BasicBaseObject { #region Cache Store private static Cache _cache = new Cache(typeof(AttnNationalHoliday)); #endregion #region Constructor public AttnNationalHoliday() { _description = string.Empty; _fromDate = DateTime.MinValue; _toDate = DateTime.MinValue; _locID = null; _status = EnumStatus.Active; } #endregion #region Input validator public string[] InputValidator() { string[] sErrorString = new string[2]; if (this.Description == "") { sErrorString[0] = "Description can not be empty"; sErrorString[1] = "Description"; return sErrorString; } sErrorString = null; return sErrorString; } #endregion #region Properties #region Description : string private string _description; public string Description { get { return _description; } set { base.OnPropertyChange("Description", _description, value); _description = value; } } #endregion #region FromDate : DateTime private DateTime _fromDate; public DateTime FromDate { get { return _fromDate; } set { base.OnPropertyChange("FromDate", _fromDate, value); _fromDate = value; } } #endregion #region ToDate : DateTime private DateTime _toDate; public DateTime ToDate { get { return _toDate; } set { base.OnPropertyChange("ToDate", _toDate, value); _toDate = value; } } #endregion #region LocationID : ID private ID _locID; public ID LocationID { get { return _locID; } set { base.OnPropertyChange("LocationID", _locID, value); _locID = value; } } #endregion #region Service Factory IAttnNationalHolidayService : IAttnNationalHolidayService internal static IAttnNationalHolidayService Service { get { return Services.Factory.CreateService(typeof(IAttnNationalHolidayService)); } } #endregion #endregion #region Functions public static AttnNationalHoliday Get(ID nID) { AttnNationalHoliday oAttnNationalHoliday = null; #region Cache Header oAttnNationalHoliday = (AttnNationalHoliday)_cache["Get", nID]; if (oAttnNationalHoliday != null) return oAttnNationalHoliday; #endregion oAttnNationalHoliday = AttnNationalHoliday.Service.Get(nID); #region Cache Footer _cache.Add(oAttnNationalHoliday, "Get", nID); #endregion return oAttnNationalHoliday; } public static ObjectsTemplate GetByMonth(DateTime fromDate, DateTime todate) { ObjectsTemplate attnNationalHolidays = null; try { attnNationalHolidays = Service.Get(fromDate, todate); } catch (ServiceException e) { throw new Exception(e.Message, e); } return attnNationalHolidays; } public static ObjectsTemplate Get(EnumStatus status) { #region Cache Header ObjectsTemplate attnNationalHolidays = _cache["Get", status] as ObjectsTemplate; if (attnNationalHolidays != null) return attnNationalHolidays; #endregion try { attnNationalHolidays = Service.Get(status); } catch (ServiceException e) { throw new Exception(e.Message, e); } #region Cache Footer _cache.Add(attnNationalHolidays, "Get", status); #endregion return attnNationalHolidays; } public ID Save() { this.SetAuditTrailProperties(); return AttnNationalHoliday.Service.Save(this); } public void Delete(ID id) { AttnNationalHoliday.Service.Delete(ID); } #endregion } #endregion #region IAttnNationalHoliday Service public interface IAttnNationalHolidayService { AttnNationalHoliday Get(ID id); ObjectsTemplate Get(DateTime fromdate, DateTime toDate); ObjectsTemplate Get(EnumStatus status ); ID Save(AttnNationalHoliday item); void Delete(ID id); } #endregion }