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 QuestionAnswer : AuditTrailBase { #region Cache Store private static Cache _cache = new Cache(typeof(QuestionAnswer)); #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 QuestionAnswer() { _answerID = null; _questionID = 0; _answerBody = string.Empty; _image = string.Empty; _isCorrect = false; _displayOrder = 0; _weight = 0; } #endregion #region Properties #region AnswerID : ID private ID _answerID; public ID AnswerID { get { return _answerID; } set { base.OnPropertyChange("AnswerID", _answerID, value); _answerID = value; } } #endregion #region QuestionID : int private int _questionID; public int QuestionID { get { return _questionID; } set { base.OnPropertyChange("QuestionID", _questionID, value); _questionID = value; } } #endregion #region AnswerBody : string private string _answerBody; public string AnswerBody { get { return _answerBody; } set { base.OnPropertyChange("AnswerBody", _answerBody, value); _answerBody = value; } } #endregion #region Image : string private string _image; public string Image { get { return _image; } set { base.OnPropertyChange("Image", _image, value); _image = value; } } #endregion #region IsCorrect : bool private bool _isCorrect; public bool IsCorrect { get { return _isCorrect; } set { base.OnPropertyChange("IsCorrect", _isCorrect, value); _isCorrect = value; } } #endregion #region DisplayOrder : int private int _displayOrder; public int DisplayOrder { get { return _displayOrder; } set { base.OnPropertyChange("DisplayOrder", _displayOrder, value); _displayOrder = value; } } #endregion #region Weight : double private double _weight; public double Weight { get { return _weight; } set { base.OnPropertyChange("Weight", _weight, value); _weight = value; } } #endregion #region Service Factory IPFTransactionService : IPFTransactionService internal static IQuestionAnswerService Service { get { return Services.Factory.CreateService(typeof(IQuestionAnswerService)); } } #endregion #endregion #region Functions public QuestionAnswer Get(ID nID) { QuestionAnswer oQuestionAnswer = null; #region Cache Header oQuestionAnswer = (QuestionAnswer)_cache["Get", ID]; if (oQuestionAnswer != null) return oQuestionAnswer; #endregion oQuestionAnswer = QuestionAnswer.Service.Get(nID); #region Cache Footer _cache.Add(oQuestionAnswer, "Get", ID); #endregion return oQuestionAnswer; } public static ObjectsTemplate Get() { #region cache header ObjectsTemplate QuestionAnswers = _cache["Get"] as ObjectsTemplate; if (QuestionAnswers != null) return QuestionAnswers; #endregion try { QuestionAnswers = Service.Get(); } catch (ServiceException e) { throw new Exception(e.Message, e); } #region cache footer _cache.Add(QuestionAnswers, "Get"); #endregion return QuestionAnswers; } public static ObjectsTemplate GetByQuestionID(ID questionId) { #region Cache Header ObjectsTemplate QuestionAnswers = _cache["Get", questionId] as ObjectsTemplate; if (QuestionAnswers != null) return QuestionAnswers; #endregion try { QuestionAnswers = Service.GetByQuestionID(questionId); } catch (ServiceException e) { throw new Exception(e.Message, e); } #region Cache Footer _cache.Add(QuestionAnswers, "Get", questionId); #endregion return QuestionAnswers; } //#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 ID Save() { base.SetAuditTrailProperties(); return QuestionAnswer.Service.Save(this); } public void Delete(ID id) { QuestionAnswer.Service.Delete(id); } #endregion } #region IQuestionAnswer Service public interface IQuestionAnswerService { QuestionAnswer Get(ID id); ObjectsTemplate Get(); ObjectsTemplate GetByQuestionID(ID questionId); ID Save(QuestionAnswer item); void Delete(ID id); } #endregion }