public async Task <BaseModel> Insert(Ref_StockWiseImagesModel stockWiseImage)
        {
            Ref_StockWiseImages stockWiseImageToDB = new Ref_StockWiseImages();

            stockWiseImageToDB.imageID  = stockWiseImage.imageID;
            stockWiseImageToDB.stockID  = stockWiseImage.stockID;
            stockWiseImageToDB.title    = stockWiseImage.title;
            stockWiseImageToDB.imageURL = stockWiseImage.imageURL;
            stockWiseImageToDB.userID   = stockWiseImage.userID;


            try
            {
                string convertedImageData = stockWiseImage.imageData.Substring(stockWiseImage.imageData.LastIndexOf(',') + 1);
                byte[] image64            = Convert.FromBase64String(convertedImageData);

                SettingsService settings  = new SettingsService(_adminConnectionString, _sCConnectionString);
                string          imagePath = settings.SelectWithinProject("IMGP").Value;
                int             count     = Directory.GetFiles(imagePath + "\\Stock\\" + stockWiseImage.stockCode + "\\", "*", SearchOption.AllDirectories).Length;
                string          filePath  = imagePath + "\\Stock\\" + stockWiseImage.stockCode + "\\Stock_Wise_Images" + (count + 1).ToString() + ".jpg";
                if (File.Exists(filePath))
                {
                    File.Delete(filePath);
                    File.WriteAllBytes(filePath, image64);
                }
                else
                {
                    Directory.CreateDirectory(Path.GetDirectoryName(filePath));
                    File.WriteAllBytes(filePath, image64);
                }


                stockWiseImageToDB.imageURL = filePath;

                using (var connection = new SqlConnection(_sCConnectionString))
                {
                    DynamicParameters para     = new DynamicParameters();
                    string            JsonData = JsonConvert.SerializeObject(stockWiseImageToDB);
                    para.Add("@JsonData", JsonData, DbType.String);
                    para.Add("@Action", "I", DbType.String);

                    await connection.ExecuteAsync("[dbo].[TAG_AD_POPULATE_StocksWiseImages]", para, commandType : System.Data.CommandType.StoredProcedure);

                    return(new BaseModel()
                    {
                        code = "1000", description = "Success", data = stockWiseImageToDB
                    });
                }
            }
            catch (Exception ex)
            {
                return(new BaseModel()
                {
                    code = "998", description = ex.Message, data = stockWiseImageToDB
                });
            }
        }
        public async Task <BaseModel> Update(UpdateData data)
        {
            Ref_StockWiseImagesModel stockWiseImage = data.NewData.ToObject <Ref_StockWiseImagesModel>();

            Ref_StockWiseImages stockWiseImageToDB = new Ref_StockWiseImages();

            stockWiseImageToDB.imageID     = stockWiseImage.imageID;
            stockWiseImageToDB.stockID     = stockWiseImage.stockID;
            stockWiseImageToDB.title       = stockWiseImage.title;
            stockWiseImageToDB.description = stockWiseImage.description;
            stockWiseImageToDB.imageURL    = stockWiseImage.imageURL;
            stockWiseImageToDB.colorCode   = stockWiseImage.colorCode;
            stockWiseImageToDB.userID      = stockWiseImage.userID;

            try
            {
                string convertedImageData = stockWiseImage.imageData.Substring(stockWiseImage.imageData.LastIndexOf(',') + 1);
                byte[] image64            = Convert.FromBase64String(convertedImageData);

                //SettingsService settings = new SettingsService(_adminConnectionString, _sCConnectionString);
                //string imagePath = settings.SelectWithinProject("IMGP").Value;

                string filePath = stockWiseImage.imageURL;
                if (File.Exists(filePath))
                {
                    File.Delete(filePath);
                    File.WriteAllBytes(filePath, image64);
                }
                else
                {
                    Directory.CreateDirectory(Path.GetDirectoryName(filePath));
                    File.WriteAllBytes(filePath, image64);
                }


                stockWiseImageToDB.imageURL = filePath;

                using (var connection = new SqlConnection(_sCConnectionString))
                {
                    DynamicParameters para        = new DynamicParameters();
                    string            JsonData    = JsonConvert.SerializeObject(stockWiseImageToDB);
                    string            OldJsonData = JsonConvert.SerializeObject(data.OldData);
                    para.Add("@JsonData", JsonData, DbType.String);
                    para.Add("@OldJsonData", OldJsonData, DbType.String);
                    para.Add("@Action", "U", DbType.String);

                    await connection.ExecuteAsync("[dbo].[TAG_AD_POPULATE_StocksWiseImages]", para, commandType : System.Data.CommandType.StoredProcedure);

                    return(new BaseModel()
                    {
                        code = "1000", description = "Success", data = stockWiseImageToDB
                    });
                }
            }
            catch (Exception ex)
            {
                return(new BaseModel()
                {
                    code = "998", description = ex.Message, data = stockWiseImageToDB
                });
            }
        }