|
|
|
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 TestimonialsDAO(DBConnectionInformation dBConnectionInformation) : base(dBConnectionInformation) { }
|
|
|
|
|
|
|
|
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.Parameters.Add(GetParameter("companyName", MySqlDbType.VarChar, 255, ParameterDirection.Input, testimonial.CompanyName));
|
|
|
|
DBCommand.Parameters.Add(GetParameter("companySpokesPerson", MySqlDbType.VarChar, 255, ParameterDirection.Input, testimonial.CompanySpokesPerson));
|
|
|
|
DBCommand.Parameters.Add(GetParameter("companyTitle", MySqlDbType.VarChar, 255, ParameterDirection.Input, testimonial.CompanyTitle));
|
|
|
|
DBCommand.Parameters.Add(GetParameter("testimonialText", MySqlDbType.Text, 65535, ParameterDirection.Input, testimonial.Testimonial));
|
|
|
|
DBCommand.Parameters.Add(GetParameter("companyWebsite", MySqlDbType.VarChar, 255, ParameterDirection.Input, testimonial.CompanyWebsite));
|
|
|
|
DBCommand.Parameters.Add(GetParameter("testimonialGUID", MySqlDbType.VarChar, 255, ParameterDirection.Input, testimonial.TestimonialGUID));
|
|
|
|
DBCommand.Parameters.Add(GetParameter("testimonialID", MySqlDbType.Int32, 0, ParameterDirection.Output, testimonial.TestimonialID));
|
|
|
|
|
|
|
|
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();
|
|
|
|
// }
|
|
|
|
//}
|
|
|
|
}
|
|
|
|
}
|