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

225 lines
6.5 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 SurveyAnswerCount : AuditTrailBase
{
#region Cache Store
private static Cache _cache = new Cache(typeof(SurveyAnswerCount));
#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 SurveyAnswerCount()
{
_surveyID = null;
_questionID = 0;
_answerID = 0;
_hitCount = 0;
}
#endregion
#region Properties
#region SurveyID : ID
private ID _surveyID;
public ID SurveyID
{
get { return _surveyID; }
set
{
base.OnPropertyChange<ID>("SurveyAnswerCountID", _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 AnswerID : int
private int _answerID;
public int AnswerID
{
get { return _answerID; }
set
{
base.OnPropertyChange<int>("AnswerID", _answerID, value);
_answerID = value;
}
}
#endregion
#region HitCount : int
private int _hitCount;
public int HitCount
{
get { return _hitCount; }
set
{
base.OnPropertyChange<int>("HitCount", _hitCount, value);
_hitCount = value;
}
}
#endregion
#region Service Factory IPFTransactionService : IPFTransactionService
internal static ISurveyAnswerCountService Service
{
get { return Services.Factory.CreateService<ISurveyAnswerCountService>(typeof(ISurveyAnswerCountService)); }
}
#endregion
#endregion
#region Functions
public SurveyAnswerCount GetSurveyAnswerCount(ID surveyId, int nQuestionId, int nAnswerId)
{
SurveyAnswerCount oSurveyAnswerCount = null;
#region Cache Header
oSurveyAnswerCount = (SurveyAnswerCount)_cache["GetSurveyAnswerCount", surveyId, nQuestionId, nAnswerId];
if (oSurveyAnswerCount != null)
return oSurveyAnswerCount;
#endregion
oSurveyAnswerCount = SurveyAnswerCount.Service.GetSurveyAnswerCount(surveyId, nQuestionId, nAnswerId);
#region Cache Footer
_cache.Add(oSurveyAnswerCount, "GetSurveyAnswerCount", surveyId, nQuestionId, nAnswerId);
#endregion
return oSurveyAnswerCount;
}
public static ObjectsTemplate<SurveyAnswerCount> GetSurveyAnswerCount()
{
#region cache header
ObjectsTemplate<SurveyAnswerCount> SurveyAnswerCounts = _cache["GetSurveyAnswerCount"] as ObjectsTemplate<SurveyAnswerCount>;
if (SurveyAnswerCounts != null)
return SurveyAnswerCounts;
#endregion
try
{
SurveyAnswerCounts = Service.GetSurveyAnswerCount();
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region cache footer
_cache.Add(SurveyAnswerCounts, "GetSurveyAnswerCount");
#endregion
return SurveyAnswerCounts;
}
public static ObjectsTemplate<SurveyAnswerCount> GetSurveyAnswerCount(ID surveyId)
{
#region Cache Header
ObjectsTemplate<SurveyAnswerCount> SurveyAnswerCounts = _cache["GetSurveyAnswerCount", surveyId] as ObjectsTemplate<SurveyAnswerCount>;
if (SurveyAnswerCounts != null)
return SurveyAnswerCounts;
#endregion
try
{
SurveyAnswerCounts = Service.GetSurveyAnswerCount(surveyId);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(SurveyAnswerCounts, "GetSurveyAnswerCount", surveyId);
#endregion
return SurveyAnswerCounts;
}
public ID Save()
{
base.SetAuditTrailProperties();
return SurveyAnswerCount.Service.Save(this);
}
public void Delete(ID id)
{
SurveyAnswerCount.Service.Delete(id);
}
#endregion
}
#region ISurveyAnswerCount Service
public interface ISurveyAnswerCountService
{
ObjectsTemplate<SurveyAnswerCount> GetSurveyAnswerCount(ID surveyId);
SurveyAnswerCount GetSurveyAnswerCount(ID surveyId, int nQuestionId, int nAnswerId);
ObjectsTemplate<SurveyAnswerCount> GetSurveyAnswerCount();
ID Save(SurveyAnswerCount item);
void Delete(ID id);
}
#endregion
}