174 lines
4.9 KiB
C#
174 lines
4.9 KiB
C#
using Ease.Core.Model;
|
|
using Ease.Core.DataAccess;
|
|
using Ease.Core;
|
|
using System.Collections.Generic;
|
|
using Ease.Core.Utility;
|
|
using HRM.BO;
|
|
using HRM.DA;
|
|
using System;
|
|
|
|
namespace HRM.DA
|
|
{
|
|
public class SurveyQuestionService : ServiceTemplate, ISurveyQuestionService
|
|
{
|
|
public SurveyQuestionService()
|
|
{
|
|
}
|
|
|
|
private void MapObject(SurveyQuestion oSurveyQuestion, DataReader oReader)
|
|
{
|
|
//base.SetObjectID(oSurveyQuestion, oReader.GetID("SurveyQuestionID"));
|
|
oSurveyQuestion.SurveyID = oReader.GetInt32("SurveyID", 0);
|
|
oSurveyQuestion.QuestionID = oReader.GetInt32("QuestionID").GetValueOrDefault();
|
|
this.SetObjectState(oSurveyQuestion, Ease.Core.ObjectState.Saved);
|
|
}
|
|
|
|
protected override T CreateObject<T>(DataReader oReader)
|
|
{
|
|
SurveyQuestion oSurveyQuestion = new SurveyQuestion();
|
|
MapObject(oSurveyQuestion, oReader);
|
|
return oSurveyQuestion as T;
|
|
}
|
|
|
|
#region Service implementation
|
|
|
|
public List<SurveyQuestion> GetSurveyQuestion(int surveyId)
|
|
{
|
|
List<SurveyQuestion> oSurveyQuestions = null;
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader dr = new DataReader(SurveyQuestionDA.GetSurveyQuestion(tc, surveyId));
|
|
oSurveyQuestions = this.CreateObjects<SurveyQuestion>(dr);
|
|
dr.Close();
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
return oSurveyQuestions;
|
|
}
|
|
|
|
public List<SurveyQuestion> GetSurveyQuestions(TransactionContext tc,string surveyIds)
|
|
{
|
|
List<SurveyQuestion> oSurveyQuestions = null;
|
|
|
|
try
|
|
{
|
|
DataReader dr = new DataReader(SurveyQuestionDA.GetSurveyQuestions(tc, surveyIds));
|
|
oSurveyQuestions = this.CreateObjects<SurveyQuestion>(dr);
|
|
dr.Close();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
return oSurveyQuestions;
|
|
}
|
|
|
|
public List<SurveyQuestion> GetSurveyQuestion()
|
|
{
|
|
List<SurveyQuestion> oSurveyQuestions = null;
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader dr = new DataReader(SurveyQuestionDA.GetSurveyQuestion(tc));
|
|
oSurveyQuestions = this.CreateObjects<SurveyQuestion>(dr);
|
|
dr.Close();
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
return oSurveyQuestions;
|
|
}
|
|
|
|
public int Save(SurveyQuestion oSurveyQuestion)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
|
|
if (oSurveyQuestion.IsNew)
|
|
{
|
|
//int id = tc.GenerateID("SurveyQuestion", "SurveyQuestionID");
|
|
//base.SetObjectID(oSurveyQuestion, (id));
|
|
|
|
|
|
SurveyQuestionDA.Insert(tc, oSurveyQuestion);
|
|
}
|
|
else
|
|
{
|
|
SurveyQuestionDA.Update(tc, oSurveyQuestion);
|
|
}
|
|
|
|
tc.End();
|
|
return oSurveyQuestion.SurveyID;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
|
|
public void Delete(int id)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
SurveyQuestionDA.Delete(tc, id);
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
} |