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.

78 lines
2.4 KiB
C#

using Common.Library.SQL.MySQL;
using System;
using System.Data;
using Common.Library.DataLayer.DTO.Websites.DMCDynamics.LLC;
using System.Collections.Generic;
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 TestimonialImagesDAO(DBConnectionInformation dBConnectionInformation) : base(dBConnectionInformation) { }
public TestimonialImagesDTO SelectOne(int testimonialID)
{
InitConnection();
try
{
TestimonialImagesDTO item = null;
DBCommand.CommandType = CommandType.StoredProcedure;
DBCommand.CommandText = "Testimonial_Images_SelectOne";
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();
}
}
}
}