public virtual void CreateContentTemplateAttachement(ContentTemplateAttachement contentTemplateAttachement)
 {
     try
     {
         Database database = DatabaseFactory.CreateDatabase("CustommerServiceConnection");
         DbCommand dbCommand = database.GetStoredProcCommand("spContentTemplateAttachementInsert");
         
         database.AddInParameter(dbCommand, "@AttachementDocument", DbType.String, contentTemplateAttachement.AttachementDocument);
         database.AddInParameter(dbCommand, "@AttachementDescription", DbType.String, contentTemplateAttachement.AttachementDescription);
         database.AddInParameter(dbCommand, "@ContentTemplateID", DbType.Int32, contentTemplateAttachement.ContentTemplateID);
         database.AddInParameter(dbCommand, "@CreatedDate", DbType.DateTime, contentTemplateAttachement.CreatedDate);
         database.AddInParameter(dbCommand, "@ModifiedDate", DbType.DateTime, contentTemplateAttachement.ModifiedDate);
         database.AddOutParameter(dbCommand, "@ContentTemplateAttachementID", DbType.Int32, 0);
         
         database.ExecuteNonQuery(dbCommand);
         contentTemplateAttachement.ContentTemplateAttachementID = (int)database.GetParameterValue(dbCommand, "@ContentTemplateAttachementID");
     }
     catch (Exception ex)
     {
         // log this exception
         log4net.Util.LogLog.Error(ex.Message, ex);
         // wrap it and rethrow
         throw new ApplicationException(SR.DataAccessCreateContentTemplateAttachementException, ex);
     }
 }
        public static void CreateContentTemplate(ContentTemplate contentTemplate, Stream attchement, string filePath, string fileName, bool keepOrignialFileName)
        {
            try
            {
                string uploadedfileName;
                ContentTemplateDAO contentTemplateDAO = new ContentTemplateDAO();
                contentTemplateDAO.CreateContentTemplate(contentTemplate);

                if (attchement.Length > 0)
                {
                    uploadedfileName = Utility.UploadService.UploadDocument(attchement, filePath, fileName, keepOrignialFileName);
                    ContentTemplateAttachement contentTemplateAttachement = new ContentTemplateAttachement();
                    contentTemplateAttachement.AttachementDocument = uploadedfileName;
                    contentTemplateAttachement.ContentTemplateID = contentTemplate.ContentTemplateID;
                    ContentTemplateAttachementService.CreateContentTemplateAttachement(contentTemplateAttachement);
                }
            }
            catch (ApplicationException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                log4net.Util.LogLog.Error(ex.Message, ex);
                // wrap it and rethrow
                throw new ApplicationException(SR.BusinessCreateContentTemplateException, ex);
            }
        }
 public static void UpdateContentTemplateAttachement(ContentTemplateAttachement contentTemplateAttachement)
 {            
     try
     {
         ContentTemplateAttachementDAO contentTemplateAttachementDAO = new ContentTemplateAttachementDAO();
         contentTemplateAttachementDAO.UpdateContentTemplateAttachement(contentTemplateAttachement);
     }
     catch (ApplicationException)
     {
         throw;
     }
     catch (Exception ex)
     {
         // log this exception
         log4net.Util.LogLog.Error(ex.Message, ex);
         // wrap it and rethrow
         throw new ApplicationException(SR.BusinessUpdateContentTemplateAttachementException, ex);
     }
 }        
 public virtual ContentTemplateAttachement CreateContentTemplateAttachementFromReader(IDataReader reader)
 {
     ContentTemplateAttachement item = new ContentTemplateAttachement();
     try
     {
         if (!reader.IsDBNull(reader.GetOrdinal("ContentTemplateAttachementID"))) item.ContentTemplateAttachementID = (int)reader["ContentTemplateAttachementID"];
         if (!reader.IsDBNull(reader.GetOrdinal("AttachementDocument"))) item.AttachementDocument = (string)reader["AttachementDocument"];
         if (!reader.IsDBNull(reader.GetOrdinal("AttachementDescription"))) item.AttachementDescription = (string)reader["AttachementDescription"];
         if (!reader.IsDBNull(reader.GetOrdinal("ContentTemplateID"))) item.ContentTemplateID = (int)reader["ContentTemplateID"];
         if (!reader.IsDBNull(reader.GetOrdinal("CreatedDate"))) item.CreatedDate = (DateTime)reader["CreatedDate"];
         if (!reader.IsDBNull(reader.GetOrdinal("ModifiedDate"))) item.ModifiedDate = (DateTime)reader["ModifiedDate"];
     }
     catch (Exception ex)
     {
         // log this exception
         log4net.Util.LogLog.Error(ex.Message, ex);
         // wrap it and rethrow
         throw new ApplicationException(SR.DataAccessCreateContentTemplateAttachementFromReaderException, ex);
     }
     return item;
 }