CEL_Payroll/Payroll.BO/Survey/SurveyEmployee.cs
2024-09-17 14:30:13 +06:00

181 lines
4.7 KiB
C#

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
{
[Serializable]
public class SurveyEmployee:AuditTrailBase
{
#region Cache Store
private static Cache _cache = new Cache(typeof(SurveyEmployee));
#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 SurveyEmployee()
{
_surveyID = null;
_employeeID = 0;
}
#endregion
#region Properties
#region SurveyID : ID
private ID _surveyID;
public ID SurveyID
{
get { return _surveyID; }
set
{
base.OnPropertyChange<ID>("SurveyID", _surveyID, value);
_surveyID = value;
}
}
#endregion
#region QuestionID : int
private int _employeeID;
public int EmployeeID
{
get { return _employeeID; }
set
{
base.OnPropertyChange<int>("EmployeeID", _employeeID, value);
_employeeID = value;
}
}
#endregion
#region Service Factory IPFTransactionService : IPFTransactionService
internal static ISurveyEmployeeService Service
{
get { return Services.Factory.CreateService<ISurveyEmployeeService>(typeof(ISurveyEmployeeService)); }
}
#endregion
#endregion
#region Functions
public static ObjectsTemplate<SurveyEmployee> GetSurveyEmployee()
{
#region cache header
ObjectsTemplate<SurveyEmployee> SurveyEmployees = _cache["GetSurveyEmployee"] as ObjectsTemplate<SurveyEmployee>;
if (SurveyEmployees != null)
return SurveyEmployees;
#endregion
try
{
SurveyEmployees = Service.GetSurveyEmployee();
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region cache footer
_cache.Add(SurveyEmployees, "GetSurveyEmployee");
#endregion
return SurveyEmployees;
}
public static ObjectsTemplate<SurveyEmployee> GetSurveyEmployee(ID surveyId)
{
#region Cache Header
ObjectsTemplate<SurveyEmployee> SurveyEmployees = _cache["GetSurveyEmployee", surveyId] as ObjectsTemplate<SurveyEmployee>;
if (SurveyEmployees != null)
return SurveyEmployees;
#endregion
try
{
SurveyEmployees = Service.GetSurveyEmployee(surveyId);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(SurveyEmployees, "GetSurveyEmployee", surveyId);
#endregion
return SurveyEmployees;
}
public ID Save()
{
base.SetAuditTrailProperties();
return SurveyEmployee.Service.Save(this);
}
public void Delete(ID id)
{
SurveyEmployee.Service.Delete(id);
}
#endregion
}
#region ISurveyEmployee Service
public interface ISurveyEmployeeService
{
ObjectsTemplate<SurveyEmployee> GetSurveyEmployee(ID surveyId);
ObjectsTemplate<SurveyEmployee> GetSurveyEmployee();
ID Save(SurveyEmployee item);
void Delete(ID id);
}
#endregion
}