CEL_Payroll/Payroll.BO/Survey/SurveyQuestion.cs

179 lines
4.3 KiB
C#
Raw Permalink Normal View History

2024-09-17 14:30:13 +06:00
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 SurveyQuestion : AuditTrailBase
{
#region Cache Store
private static Cache _cache = new Cache(typeof(SurveyQuestion));
#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 SurveyQuestion()
{
_surveyID = null;
_questionID = 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 _questionID;
public int QuestionID
{
get { return _questionID; }
set
{
base.OnPropertyChange<int>("QuestionID", _questionID, value);
_questionID = value;
}
}
#endregion
#region Service Factory IPFTransactionService : IPFTransactionService
internal static ISurveyQuestionService Service
{
get { return Services.Factory.CreateService<ISurveyQuestionService>(typeof(ISurveyQuestionService)); }
}
#endregion
#endregion
#region Functions
public static ObjectsTemplate<SurveyQuestion> GetSurveyQuestion()
{
#region cache header
ObjectsTemplate<SurveyQuestion> SurveyQuestions = _cache["GetSurveyQuestion"] as ObjectsTemplate<SurveyQuestion>;
if (SurveyQuestions != null)
return SurveyQuestions;
#endregion
try
{
SurveyQuestions = Service.GetSurveyQuestion();
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region cache footer
_cache.Add(SurveyQuestions, "GetSurveyQuestion");
#endregion
return SurveyQuestions;
}
public static ObjectsTemplate<SurveyQuestion> GetSurveyQuestion(ID surveyId)
{
#region Cache Header
ObjectsTemplate<SurveyQuestion> SurveyQuestions = _cache["GetSurveyQuestion", surveyId] as ObjectsTemplate<SurveyQuestion>;
if (SurveyQuestions != null)
return SurveyQuestions;
#endregion
try
{
SurveyQuestions = Service.GetSurveyQuestion(surveyId);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(SurveyQuestions, "GetSurveyQuestion", surveyId);
#endregion
return SurveyQuestions;
}
public ID Save()
{
base.SetAuditTrailProperties();
return SurveyQuestion.Service.Save(this);
}
public void Delete(ID id)
{
SurveyQuestion.Service.Delete(id);
}
#endregion
}
#region ISurveyQuestion Service
public interface ISurveyQuestionService
{
ObjectsTemplate<SurveyQuestion> GetSurveyQuestion(ID surveyId);
ObjectsTemplate<SurveyQuestion> GetSurveyQuestion();
ID Save(SurveyQuestion item);
void Delete(ID id);
}
#endregion
}