using System; using System.Data; using System.Linq; using System.Collections.Generic; using HRM.BO; using HRM.DA; using Ease.Core.Model; using Ease.Core.DataAccess; using Ease.Core.Utility; using Ease.Core; using NPOI.SS.Formula.Functions; using System.Net.Mail; namespace HRM.DA { public class LMSTemplateService { public LMSTemplateService() { } #region GET public List GetCourseTemplates(TransactionContext tc, int objectID) { List oLMSTemplates = new List(); try { DataReader oreader = new DataReader(LMSTemplateDA.GetLMSTemplate(tc, objectID)); while (oreader.Read()) { LMSTemplate oLMSTemplate = new LMSTemplate(); oLMSTemplate.TemplateID = oreader.GetInt32("TemplateID").Value; oLMSTemplate.ObjectID = oreader.GetInt32("ObjectID").Value; oLMSTemplate.TemplateType = (EnumTemplateType)oreader.GetInt32("TemplateType").Value; oLMSTemplate.FileAsByteArray = oreader.GetLob("FileData"); oLMSTemplate.FileName = oreader.GetString("FileName"); oLMSTemplate.FileType = (EnumFileType)oreader.GetInt32("FileType").GetValueOrDefault(); oLMSTemplates.Add(oLMSTemplate); } oreader.Close(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return oLMSTemplates; } public LMSTemplate GetCourseTemplate(TransactionContext tc, int objectID) { LMSTemplate oLMSTemplate = new LMSTemplate(); try { DataReader oreader = new DataReader(LMSTemplateDA.GetLMSTemplate(tc, objectID)); while (oreader.Read()) {; oLMSTemplate.TemplateID = oreader.GetInt32("TemplateID").Value; oLMSTemplate.ID = oLMSTemplate.TemplateID; oLMSTemplate.ObjectID = oreader.GetInt32("ObjectID").Value; oLMSTemplate.TemplateType = (EnumTemplateType)oreader.GetInt32("TemplateType").Value; oLMSTemplate.FileAsByteArray = oreader.GetLob("FileData"); oLMSTemplate.FileName = oreader.GetString("FileName"); oLMSTemplate.FileType = (EnumFileType)oreader.GetInt32("FileType").GetValueOrDefault(); } oreader.Close(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return oLMSTemplate; } #endregion } }