You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

112 lines
3.5 KiB
C#

using Common.Library.SQL.MySQL;
using System;
using System.Data;
using Common.Library.DataLayer.DTO.Websites.JasonNeumannAudio.com;
namespace Common.Library.DataLayer.DAO.Websites.JasonNeumannAudio.com
{
public class WorkPageDAO : MySQL
{
public WorkPageDAO(DBConnectionInformation connectionInformation) : base(connectionInformation){ }
public WorkPageDTO SelectOne(WorkPageDTO.WorkPageType workPageType)
{
InitConnection();
WorkPageDTO item = null;
try
{
DBCommand.CommandType = CommandType.StoredProcedure;
DBCommand.CommandText = "work_page_select_one";
DBCommand.Parameters.AddWithValue("@TypeID", (int)workPageType);
DBReader = DBCommand.ExecuteReader();
if(DBReader.Read())
{
item = new()
{
WorkPageID = GetInt("WorkPageID").Value,
WorkPageTypeID = (WorkPageDTO.WorkPageType)GetInt("WorkPageTypeID").Value,
WorkPageName = GetString("WorkPageName"),
WorkPageLink = GetString("WorkPageLink"),
WorkPageValue = FormatBoldForHTML(GetString("WorkPageValue"))
};
}
return item;
}
catch(Exception)
{
throw;
}
finally
{
DisposeConnection();
}
}
public WorkPageDTOCollection SelectAllByWorkPageType(WorkPageDTO.WorkPageType workPageType)
{
InitConnection();
WorkPageDTOCollection items = new();
try
{
DBCommand.CommandType = CommandType.StoredProcedure;
DBCommand.CommandText = "work_page_select_all_by_work_page_type";
DBCommand.Parameters.AddWithValue("@TypeID", (int)workPageType);
DBReader = DBCommand.ExecuteReader();
while (DBReader.Read())
{
WorkPageDTO item = new()
{
// WorkPageID = GetInt("WorkPageID").Value,
WorkPageTypeID = (WorkPageDTO.WorkPageType)GetInt("WorkPageTypeID").Value,
WorkPageName = GetString("WorkPageName"),
WorkPageLink = GetString("WorkPageLink"),
WorkPageValue = FormatBoldForHTML(GetString("WorkPageValue"))
};
items.Add(item);
}
return items.Count == 0 ? null : items;
}
catch (Exception)
{
throw;
}
finally
{
DisposeConnection();
}
}
4 years ago
// public void InsertWorkPageItem(WorkPageDTO item)
// {
// InitConnection();
// WorkPageDTOCollection items = new();
// try
// {
// DBCommand.CommandType = CommandType.StoredProcedure;
// DBCommand.CommandText = "work_page_insert_work_page_item";
// // DBCommand.Parameters.AddWithValue("@TypeID", (int)workPageType);
// DBCommand.ExecuteNonQuery();
// }
// catch (Exception)
// {
// throw;
// }
// finally
// {
// DisposeConnection();
// }
// }
}
}