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.

110 lines
3.1 KiB
C#

using Common.Library.SQL.MySQL;
using System;
using System.Data;
using Common.Library.DataLayer.DTO.Websites.DMCDynamics.LLC;
using System.Collections.Generic;
using MySql.Data.MySqlClient;
namespace Common.Library.DataLayer.DAO.Websites.DMCDynamics.LLC
{
public class TestimonialsDAO : MySQL
{
public TestimonialsDAO(string server, string database, string username, string password) : base(server, database, username, password)
{
}
public TestimonialsDTOCollection SelectAll()
{
InitConnection();
try
{
TestimonialsDTOCollection items = new();
DBCommand.CommandType = CommandType.StoredProcedure;
DBCommand.CommandText = "Testimonials_SelectAll";
DBReader = DBCommand.ExecuteReader();
while (DBReader.Read())
{
TestimonialsDTO item = new()
{
TestimonialID = GetInt("TestimonialID").Value,
CompanyName = GetString("CompanyName"),
CompanySpokesPerson = GetString("CompanySpokesPerson"),
CompanyTitle = GetString("CompanyTitle"),
CompanyWebsite = GetString("CompanyWebsite"),
Testimonial = GetString("Testimonial")
};
items.Add(item);
}
return (items.Count == 0 ? null : items);
}
catch (Exception)
{
throw;
}
finally
{
DisposeConnection();
}
}
public int Insert(TestimonialsDTO testimonial)
{
InitConnection();
try
{
DBCommand.CommandType = CommandType.StoredProcedure;
DBCommand.CommandText = "Testimonials_Insert";
//> Add parameters
DBCommand.ExecuteNonQuery();
return (int)DBCommand.Parameters["TestimonialID"].Value;
}
catch(Exception)
{
throw;
}
finally
{
DisposeConnection();
}
}
//public void InsertImage(int testimonialID, KeyValuePair<string, byte[]> imageData)
//{
// InitConnection();
// try
// {
// DBCommand.CommandType = CommandType.StoredProcedure;
// DBCommand.CommandText = "Testimonial_Images_Insert";
// DBCommand.Parameters.AddWithValue("@testimonialID", testimonialID);
// DBCommand.Parameters.AddWithValue("@imageType", imageData.Key);
// DBCommand.Parameters.AddWithValue("@imageData", imageData.Value);
// DBCommand.ExecuteNonQuery();
// }
// catch (Exception)
// {
// throw;
// }
// finally
// {
// DisposeConnection();
// }
//}
}
}