public string GetAdPurcDetails(string sAdPostID, string sAdUserID)
 {
     try
     {
         DALComponent objDAL = new DALComponent();
         objDAL.SetParameters("@adpostId", SqlDbType.Int, 4, Convert.ToInt32(sAdPostID));
         objDAL.SetParameters("@userId", SqlDbType.Int, 4, Convert.ToInt32(sAdUserID));
         objDAL.SqlCommandText = "[GetAdPurcDetails]";
         string s = GetJson(objDAL.SelectRecord());
         return s;
     }
     catch (SqlException sqlEx)
     {
         return sqlEx.Message.ToString();
     }
     catch (Exception ex)
     {
         return ex.Message.ToString();
     }
 }
 public string SelectChargeDetailsByID(string strChargeId)
 {
     try
     {
         DALComponent objDAL = new DALComponent();
         objDAL.SetParameters("@chargeId", SqlDbType.Int, 4, Convert.ToInt32(strChargeId));
         objDAL.SqlCommandText = "SelectChargeDetailsByID";
         return GetJson(objDAL.SelectRecord());
     }
     catch (SqlException sqlEx)
     {
         throw new ApplicationException("Data error=" + sqlEx.Message.ToString());
     }
     catch (Exception ex)
     {
         throw new ApplicationException("Error=" + ex.Message.ToString());
     }
 }
 public DataTable GetAdDetailsDT(UserAdpost adpostDetails)
 {
     try
     {
         DALComponent objDALComponent1 = new DALComponent();
         objDALComponent1.SetParameters("@adpostId", SqlDbType.Int, 4, adpostDetails.AdPostId);
         objDALComponent1.SetParameters("@userId", SqlDbType.Int, 4, adpostDetails.UserId);
         objDALComponent1.SqlCommandText = "[GetAdDetails]";
         return objDALComponent1.SelectRecord();
     }
     catch (SqlException sqlEx)
     {
         throw new ApplicationException("Data error=" + sqlEx.Message.ToString());
     }
     catch (Exception ex)
     {
         throw new ApplicationException("Error=" + ex.Message.ToString());
     }
 }
        public string AddAdImageDetails(AdImageDetails adimageDetails)
        {
            try
            {
                /*string[] strImg = new string[5];
                HttpPostedFile postedFile = strImg[0] as HttpPostedFile;
                strImg = adimageDetails.ImagePath.Split(':');
                string path = string.Empty;
                string strImgFinalPath = "";
                string finalPath = string.Empty;
                string filePath = string.Empty;
                int userId = 0;// Convert.ToInt32(Session["UserId"].ToString());
                string sFilename = "";
                if (FileUpload1.PostedFile != null)
                {
                    HttpPostedFile myFile = FileUpload1.PostedFile;
                    int nFileLen = myFile.ContentLength;
                    if (nFileLen != 0)
                    {
                        DirectoryInfo dirInfo = null;
                        fileSavePath = "/Data/TS_" + userId + "/Images/";
                        path = Server.MapPath("~" + fileSavePath);
                        if (!Directory.Exists(path))
                        {
                            dirInfo = Directory.CreateDirectory(path);
                        }
                        sFilename = System.IO.Path.GetFileName(myFile.FileName);
                        path = path + "/" + sFilename;
                        FileUpload1.PostedFile.SaveAs(path);

                        finalPath = Path.Combine(fileSavePath, sFilename);
                    }
                }
                strImgFinalPath = finalPath;

                if (FileUpload2.PostedFile != null)
                {
                    HttpPostedFile myFile = FileUpload2.PostedFile;
                    int nFileLen = myFile.ContentLength;
                    if (nFileLen != 0)
                    {
                        path = Server.MapPath("~" + fileSavePath);
                        sFilename = System.IO.Path.GetFileName(myFile.FileName);
                        path = path + "/" + sFilename;
                        FileUpload2.PostedFile.SaveAs(path);

                        finalPath = Path.Combine(fileSavePath, sFilename);

                        strImgFinalPath = strImgFinalPath + ":" + finalPath;
                    }
                }

                if (FileUpload3.PostedFile != null)
                {
                    HttpPostedFile myFile = FileUpload3.PostedFile;
                    int nFileLen = myFile.ContentLength;
                    if (nFileLen != 0)
                    {
                        path = Server.MapPath("~" + fileSavePath);
                        sFilename = System.IO.Path.GetFileName(myFile.FileName);
                        path = path + "/" + sFilename;
                        FileUpload3.PostedFile.SaveAs(path);

                        finalPath = Path.Combine(fileSavePath, sFilename);
                        strImgFinalPath = strImgFinalPath + ":" + finalPath;
                    }
                }

                if (FileUpload4.PostedFile != null)
                {
                    HttpPostedFile myFile = FileUpload4.PostedFile;
                    int nFileLen = myFile.ContentLength;
                    if (nFileLen != 0)
                    {
                        path = Server.MapPath("~" + fileSavePath);
                        sFilename = System.IO.Path.GetFileName(myFile.FileName);
                        path = path + "/" + sFilename;
                        FileUpload4.PostedFile.SaveAs(path);

                        finalPath = Path.Combine(fileSavePath, sFilename);
                        strImgFinalPath = strImgFinalPath + ":" + finalPath;
                    }
                }

                if (FileUpload5.PostedFile != null)
                {
                    HttpPostedFile myFile = FileUpload5.PostedFile;
                    int nFileLen = myFile.ContentLength;
                    if (nFileLen != 0)
                    {
                        path = Server.MapPath("~" + fileSavePath);
                        sFilename = System.IO.Path.GetFileName(myFile.FileName);
                        path = path + "/" + sFilename;
                        FileUpload5.PostedFile.SaveAs(path);

                        finalPath = Path.Combine(fileSavePath, sFilename);
                        strImgFinalPath = strImgFinalPath + ":" + finalPath;
                    }
                }*/
                DALComponent objDAL = new DALComponent();
                objDAL.SetParameters("@imageId", SqlDbType.Int, 4, adimageDetails.ImageId);
                objDAL.SetParameters("@adpostId", SqlDbType.Int, 4, adimageDetails.AdPostId);
                objDAL.SetParameters("@imagePath", SqlDbType.VarChar, 1000, adimageDetails.ImagePath);
                objDAL.SetParameters("@videoLink", SqlDbType.VarChar, 1000, adimageDetails.VideoLink);
                objDAL.SetParameters("@idvalue", SqlDbType.Int, true);

                objDAL.SqlCommandText = "CreateAdImageDetails";
                int x = objDAL.CreateRecord();

                object y = objDAL.GetParameters("@idvalue");

                return y.ToString();
            }
            catch (SqlException sqlEx)
            {
                return sqlEx.Message.ToString();
            }
            catch (Exception ex)
            {
                return ex.Message.ToString();
            }
        }
        public int CreateBuyDetails(AdStatusDetails adStatusDetails)
        {
            try
            {
                DALComponent oDal = new DALComponent();
                oDal.SetParameters("@adpostid", SqlDbType.Int, 4, adStatusDetails.AdPostId);
                oDal.SetParameters("@historyId", SqlDbType.Int, 4, adStatusDetails.HistroyId);
                oDal.SetParameters("@userId", SqlDbType.Int, 4, adStatusDetails.UserId_Buyer);
                oDal.SetParameters("@totalprice", SqlDbType.Decimal, 9, Convert.ToDecimal(adStatusDetails.TotalPrice));
                oDal.SetParameters("@delitype", SqlDbType.Int, 4, adStatusDetails.DeliveryType);
                oDal.SetParameters("@cityId", SqlDbType.Int, 4, adStatusDetails.SaleLocationId);
                oDal.SetParameters("@currentstatus", SqlDbType.VarChar, 50, adStatusDetails.CurrentStatus);
                oDal.SetParameters("@viewcount", SqlDbType.Int, 4, adStatusDetails.ViewersCount);
                oDal.SetParameters("@chargeName", SqlDbType.VarChar, 50, adStatusDetails.ChargeName);
                oDal.SetParameters("@chargeType", SqlDbType.Int, 4, adStatusDetails.ChargeType);
                oDal.SetParameters("@chargeAmount", SqlDbType.Float, 9, Convert.ToDouble(adStatusDetails.ChargeAmount));
                oDal.SetParameters("@idvalue", SqlDbType.Int, true);

                oDal.SqlCommandText = "[CreateBuyDetails]";
                int x = oDal.CreateRecord();

                return x;
            }
            catch (SqlException sqlEx)
            {
                throw new ApplicationException("Data error=" + sqlEx.Message.ToString());
            }
            catch (Exception ex)
            {
                throw new ApplicationException("Error=" + ex.Message.ToString());
            }
        }
 public string AvailableMail(string strEmail)
 {
     try
     {
         DALComponent objDAL = new DALComponent();
         objDAL.SetParameters("@email", SqlDbType.VarChar, 50, strEmail);
         objDAL.SqlCommandText = "[AvailableMail]";
         return GetJson(objDAL.SelectRecord());
     }
     catch (SqlException sqlEx)
     {
         throw new ApplicationException("Data error=" + sqlEx.Message.ToString());
     }
     catch (Exception ex)
     {
         throw new ApplicationException("Error=" + ex.Message.ToString());
     }
 }
        public int AddAdPost(AdPostDetails adpostDetails)
        {
            try
            {
                DALComponent objDAL = new DALComponent();
                objDAL.SetParameters("@adpostId", SqlDbType.Int, 4, adpostDetails.AdPostId);
                objDAL.SetParameters("@adpostTitle", SqlDbType.VarChar, 500, adpostDetails.AdPostTitle);
                objDAL.SetParameters("@description", SqlDbType.VarChar, 1000, adpostDetails.Description);
                objDAL.SetParameters("@keywords", SqlDbType.VarChar, 1000, adpostDetails.Keywords);
                objDAL.SetParameters("@userId", SqlDbType.Int, 4, adpostDetails.UserId);
                objDAL.SetParameters("@categoryId", SqlDbType.Int, 4, adpostDetails.CategoryId);
                objDAL.SetParameters("@price", SqlDbType.Decimal, 9, Convert.ToDecimal(adpostDetails.Price));
                objDAL.SetParameters("@stateId", SqlDbType.Int, 4, adpostDetails.StateId);
                objDAL.SetParameters("@cityId", SqlDbType.Int, 4, adpostDetails.CityId);
                objDAL.SetParameters("@countryId", SqlDbType.Int, 4, adpostDetails.CountryId);
                objDAL.SetParameters("@zipCode", SqlDbType.VarChar, 50, adpostDetails.ZipCode);
                objDAL.SetParameters("@adtillDate", SqlDbType.SmallDateTime, 4, adpostDetails.AdTillDate);
                objDAL.SetParameters("@adStatus", SqlDbType.VarChar, 50, adpostDetails.AdStatus);
                objDAL.SetParameters("@paidStatus", SqlDbType.Int, 4, adpostDetails.PaidStatus);
                objDAL.SetParameters("@idvalue", SqlDbType.Int, true);

                objDAL.SqlCommandText = "CreateAdPost";
                int x = objDAL.CreateRecord();

                object y = objDAL.GetParameters("@idvalue");

                if (adpostDetails.AdPostId != 0)
                    return adpostDetails.AdPostId;
                else
                    return Int32.Parse(y.ToString());
            }
            catch (SqlException sqlEx)
            {
                throw new ApplicationException("Data error=" + sqlEx.Message.ToString());
            }
            catch (Exception ex)
            {
                throw new ApplicationException("Error=" + ex.Message.ToString());
            }
        }