143 lines
4.3 KiB
C#
143 lines
4.3 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;
|
|
using System.Data;
|
|
|
|
namespace HRM.DA
|
|
{
|
|
public class SurveyWeightDefinitionService : ServiceTemplate, ISurveyWeightDefinitionService
|
|
{
|
|
public SurveyWeightDefinitionService()
|
|
{
|
|
}
|
|
|
|
private void MapObject(SurveyWeightDefinition oSurveyWeightDefinition, DataReader oReader)
|
|
{
|
|
oSurveyWeightDefinition.SurveyID = oReader.GetInt32("SurveyID", 0);
|
|
oSurveyWeightDefinition.FromWeight = oReader.GetDouble("FromWeight").Value;
|
|
oSurveyWeightDefinition.ToWeight = oReader.GetDouble("ToWeight").Value;
|
|
oSurveyWeightDefinition.Remark = oReader.GetString("Remark");
|
|
this.SetObjectState(oSurveyWeightDefinition, Ease.Core.ObjectState.Saved);
|
|
}
|
|
|
|
protected override T CreateObject<T>(DataReader oReader)
|
|
{
|
|
SurveyWeightDefinition oSurveyWeightDefinition = new SurveyWeightDefinition();
|
|
MapObject(oSurveyWeightDefinition, oReader);
|
|
return oSurveyWeightDefinition as T;
|
|
}
|
|
|
|
#region Service implementation
|
|
|
|
public List<SurveyWeightDefinition> GetSurveyWeightDefinition(int surveyId)
|
|
{
|
|
List<SurveyWeightDefinition> oSurveyWeightDefinitions = null;
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader dr = new DataReader(SurveyWeightDefinitionDA.GetSurveyWeightDefinition(tc, surveyId));
|
|
oSurveyWeightDefinitions = this.CreateObjects<SurveyWeightDefinition>(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 oSurveyWeightDefinitions;
|
|
}
|
|
|
|
public List<SurveyWeightDefinition> GetSurveyWeightDefinition()
|
|
{
|
|
List<SurveyWeightDefinition> oSurveyWeightDefinitions = null;
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader dr = new DataReader(SurveyWeightDefinitionDA.GetSurveyWeightDefinition(tc));
|
|
oSurveyWeightDefinitions = this.CreateObjects<SurveyWeightDefinition>(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 oSurveyWeightDefinitions;
|
|
}
|
|
|
|
public int Save(SurveyWeightDefinition oSurveyWeightDefinition)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
|
|
SurveyWeightDefinitionDA.DeleteSurveyWeightDefinition(tc, oSurveyWeightDefinition.SurveyID);
|
|
SurveyWeightDefinitionDA.Insert(tc, oSurveyWeightDefinition);
|
|
tc.End();
|
|
return oSurveyWeightDefinition.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);
|
|
SurveyWeightDefinitionDA.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
|
|
}
|
|
} |