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 Loan [Serializable] public class Loan : BasicBaseObject { #region Cache Store private static Cache _cache = new Cache(typeof(Loan)); #endregion #region Constructor public Loan() { _name = string.Empty; _isConfirmationRequired = false; _interestRate = 0; _status = EnumStatus.Active; } #endregion #region Input validator public string[] InputValidator() { string[] sErrorString = new string[1]; if (this.Name == "") { sErrorString[0] = "Name can not be empty"; sErrorString[1] = "Name"; return sErrorString; } sErrorString = null; return sErrorString; } #endregion #region Properties #region name : string private string _name; public string Name { get { return _name; } set { base.OnPropertyChange("name", _name, value); _name = value; } } #endregion #region isConfirmationRequired : bool private bool _isConfirmationRequired; public bool IsConfirmationRequired { get { return _isConfirmationRequired; } set { base.OnPropertyChange("isConfirmationRequired", _isConfirmationRequired, value); _isConfirmationRequired = value; } } #endregion #region interestRate : double private double _interestRate; public double InterestRate { get { return _interestRate; } set { base.OnPropertyChange("interestRate", _interestRate, value); _interestRate = value; } } #endregion #region Service Factory ILoanService : ILoanService internal static ILoanService Service { get { return Services.Factory.CreateService(typeof(ILoanService)); } } #endregion #endregion #region Functions public static Loan Get(ID nID) { Loan oLoan = null; #region Cache Header oLoan = (Loan)_cache["Get", nID]; if (oLoan != null) return oLoan; #endregion oLoan = Loan.Service.Get(nID); #region Cache Footer _cache.Add(oLoan, "Get", nID); #endregion return oLoan; } public static ObjectsTemplate Get(EnumStatus status) { #region Cache Header ObjectsTemplate loans = _cache["Get",status] as ObjectsTemplate; if (loans != null) return loans; #endregion try { loans = Service.Get(status); } catch (ServiceException e) { throw new Exception(e.Message, e); } #region Cache Footer _cache.Add(loans, "Get",status); #endregion return loans; } public ID Save() { this.SetAuditTrailProperties(); return Loan.Service.Save(this); } public void Delete(ID id) { Loan.Service.Delete(id); } #endregion public static Loan Get(string loanNo) { Loan oLoan = null; #region Cache Header oLoan = (Loan)_cache["Get", loanNo]; if (oLoan != null) return oLoan; #endregion oLoan = Loan.Service.Get(loanNo); #region Cache Footer _cache.Add(oLoan, "Get", loanNo); #endregion return oLoan; } } #endregion #region ILoan Service public interface ILoanService { Loan Get(ID id); ObjectsTemplate Get(EnumStatus status); ID Save(Loan item); void Delete(ID id); Loan Get(string loanNo); } #endregion }