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 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(); } } } }