EchoTex_Payroll/HRM.DA/Service/Recruitement/WebAPPFormParamService.cs

380 lines
12 KiB
C#
Raw Normal View History

2024-10-14 10:01:49 +06:00
using System;
using System.Data;
using Ease.Core.Model;
using Ease.Core.DataAccess;
using Ease.Core;
using System.Collections.Generic;
using Ease.Core.Utility;
using HRM.BO;
namespace HRM.DA
{
#region WebAPPFormParam Service
public class WebAPPFormParamService : ServiceTemplate, IWebAPPFormParamService
{
public WebAPPFormParamService()
{
}
#region MapObject For WebAPPFormParam
private void MapObject(WebAPPFormParam owebAPPFormParam, DataReader oReader)
{
base.SetObjectID(owebAPPFormParam, (oReader.GetInt32("WebAPPParamID").Value));
owebAPPFormParam.AssessmentFormType = (EnumAssessmentFormType)oReader.GetInt32("AssessmentFormType").Value;
owebAPPFormParam.FormID = oReader.GetInt32("FormID").Value;
owebAPPFormParam.ObjectID = oReader.GetInt32("ObjectID").Value;
owebAPPFormParam.AssessmentBy = oReader.GetInt32("AssessmentBy", 0);
owebAPPFormParam.AssessmentFor = (EnumAssessmentFor)oReader.GetInt32("AssessmentFor").Value;
owebAPPFormParam.AssessmentDate =
oReader.GetDateTime("AssessmentDate").GetValueOrDefault(DateTime.MinValue);
owebAPPFormParam.CreatedBy = oReader.GetInt32("CreatedBy", 0);
owebAPPFormParam.CreatedDate = oReader.GetDateTime("CreationDate").Value;
owebAPPFormParam.ModifiedBy = oReader.GetInt32("ModifiedBy", 0);
;
owebAPPFormParam.ModifiedDate = oReader.GetDateTime("ModifiedDate");
this.SetObjectState(owebAPPFormParam, Ease.Core.ObjectState.Saved);
}
protected override T CreateObject<T>(DataReader oReader)
{
WebAPPFormParam owebAPPFormParam = new WebAPPFormParam();
MapObject(owebAPPFormParam, oReader);
return owebAPPFormParam as T;
}
protected WebAPPFormParam CreateObject(DataReader oReader)
{
WebAPPFormParam owebAPPFormParam = new WebAPPFormParam();
MapObject(owebAPPFormParam, oReader);
return owebAPPFormParam;
}
#endregion
#region MapObject For WebAPPFormParamDetails
private void MapWebAPPFormParamDetails(WebAPPFormParamDetails oWebAPPFormParamDetails, DataReader oReader)
{
base.SetObjectID(oWebAPPFormParamDetails, (oReader.GetInt32("ParamDetailsID").Value));
oWebAPPFormParamDetails.WebAPPParamID = oReader.GetInt32("WebAPPParamID", 0);
oWebAPPFormParamDetails.ParamID = oReader.GetInt32("ParamID").Value;
oWebAPPFormParamDetails.Value = (object)oReader.GetString("Value");
oWebAPPFormParamDetails.DataType = (EnumColumnDataType)oReader.GetInt32("DataType").Value;
this.SetObjectState(oWebAPPFormParamDetails, Ease.Core.ObjectState.Saved);
}
protected List<WebAPPFormParamDetails> CreateWebAPPFormParamDetailsObject(DataReader oReader)
{
List<WebAPPFormParamDetails> oWebAPPFormParamDetails = new List<WebAPPFormParamDetails>();
while (oReader.Read())
{
WebAPPFormParamDetails oWebAPPFormParamDetail = new WebAPPFormParamDetails();
MapWebAPPFormParamDetails(oWebAPPFormParamDetail, oReader);
oWebAPPFormParamDetails.Add(oWebAPPFormParamDetail);
}
return oWebAPPFormParamDetails;
}
#endregion
#region Service Implementation
public WebAPPFormParam Get(int id)
{
WebAPPFormParam oWebAPPFormParam = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader oreader = new DataReader(WebAPPFormParamDA.Get(tc, id));
if (oreader.Read())
{
oWebAPPFormParam = this.CreateObject<WebAPPFormParam>(oreader);
}
oreader.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 oWebAPPFormParam;
}
public WebAPPFormParam Get(int formId, int objectID)
{
WebAPPFormParam oWebAPPFormParam = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader oreader = new DataReader(WebAPPFormParamDA.Get(tc, formId, objectID));
if (oreader.Read())
{
oWebAPPFormParam = this.CreateObject<WebAPPFormParam>(oreader);
}
oreader.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 oWebAPPFormParam;
}
public List<WebAPPFormParam> Get()
{
List<WebAPPFormParam> oWebAPPFormParams = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(WebAPPFormParamDA.Get(tc));
oWebAPPFormParams = this.CreateObjects<WebAPPFormParam>(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 oWebAPPFormParams;
}
public List<WebAPPFormParam> GetParams(int formId, int objectID)
{
List<WebAPPFormParam> oWebAPPFormParams = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(WebAPPFormParamDA.GetParams(tc, formId, objectID));
oWebAPPFormParams = this.CreateObjects<WebAPPFormParam>(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 oWebAPPFormParams;
}
public int Save(WebAPPFormParam oWebAPPFormParam)
{
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
if (oWebAPPFormParam.IsNew)
{
int id = tc.GenerateID("AssessmentMaster", "WebAPPParamID");
base.SetObjectID(oWebAPPFormParam, (id));
WebAPPFormParamDA.Insert(tc, oWebAPPFormParam);
}
else
{
WebAPPFormParamDA.DeleteParamDetails(tc, oWebAPPFormParam.ID);
WebAPPFormParamDA.Update(tc, oWebAPPFormParam);
}
foreach (WebAPPFormParamDetails oWebAPPFormParamDetails in oWebAPPFormParam.ParamDetails)
{
oWebAPPFormParamDetails.WebAPPParamID = oWebAPPFormParam.ID;
int paramDetailsID = tc.GenerateID("AssessmentDetail", "ParamDetailsID");
base.SetObjectID(oWebAPPFormParamDetails, (paramDetailsID));
WebAPPFormParamDA.InsertParamDetails(tc, oWebAPPFormParamDetails);
}
return oWebAPPFormParam.ID;
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
finally
{
tc.End();
}
}
public void Delete(int formId, int objectID)
{
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
WebAPPFormParamDA.Delete(tc, formId, objectID);
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
finally
{
tc.End();
}
}
public void Delete(int id)
{
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
WebAPPFormParamDA.DeleteParamDetails(tc, id);
WebAPPFormParamDA.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
}
}
public void Save(List<WebAPPFormParam> oWebAPPFormParams)
{
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
if (oWebAPPFormParams.Count > 0)
{
foreach (WebAPPFormParam appItem in oWebAPPFormParams)
{
if (appItem.IsNew)
{
int id = tc.GenerateID("AssessmentMaster", "WebAPPParamID");
base.SetObjectID(appItem, (id));
WebAPPFormParamDA.Insert(tc, appItem);
}
else
{
WebAPPFormParamDA.Update(tc, appItem);
}
}
}
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
finally
{
tc.End();
}
}
public List<WebAPPFormParamDetails> GetParamDetails(int ParamId)
{
List<WebAPPFormParamDetails> paramDetails = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(WebAPPFormParamDA.GetParamDetails(tc, ParamId));
paramDetails = this.CreateWebAPPFormParamDetailsObject(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 paramDetails;
}
#endregion
}
#endregion
}