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.

79 lines
2.3 KiB
C#

using Common.Library.SQL.MySQL;
using System;
using System.Data;
4 years ago
using Common.Library.DataLayer.DTO.Websites.DMCDynamics.LLC;
using System.Collections.Generic;
4 years ago
namespace Common.Library.DataLayer.DAO.Websites.DMCDynamics.LLC
{
public class TestimonialImagesDAO : MySQL
{
public TestimonialImagesDAO(string server, string database, string username, string password) : base(server, database, username, password)
{
}
public TestimonialImagesDTO SelectOne(int testimonialID)
{
InitConnection();
try
{
TestimonialImagesDTO item = null;
DBCommand.CommandType = CommandType.StoredProcedure;
DBCommand.CommandText = "Testimonial_Images_SelectOne";
4 years ago
DBCommand.Parameters.AddWithValue("tID", testimonialID);
DBReader = DBCommand.ExecuteReader();
if (DBReader.Read())
{
item = new TestimonialImagesDTO()
{
TestimonialImageID = GetInt("TestimonialImageID").Value,
TestimonialID = GetInt("TestimonialID").Value,
ImageType = GetString("ImageType"),
ImageData = GetBytes("ImageData")
};
}
return item;
}
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();
}
}
}
}