private IImage ConvertImage(IImageDTO imageDTO) { return(new Image() { Id = imageDTO.Id, OfferedServiceId = imageDTO.OfferedServiceId, ImageAsString = "data:image/jpeg;base64," + Convert.ToBase64String(imageDTO.Image, 0, imageDTO.Image.Length), IsHeadImage = Convert.ToBoolean(imageDTO.IsHeadImage) }); }
public void AddImage(IImageDTO imageDTO) { using var connection = MySqlFactory.CreateConnection(); connection.Open(); var cmd = MySqlFactory.CreateCommand("AddImage", connection); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@offeredServiceId", imageDTO.OfferedServiceId); cmd.Parameters.AddWithValue("@image", imageDTO.Image); cmd.Parameters.AddWithValue("@isHeadImage", imageDTO.IsHeadImage); cmd.ExecuteNonQuery(); connection.Close(); }