public ActionResult Add(Property p) { int check = 0; SqlConnection con = new SqlConnection(p.Con); DataSet ds = new DataSet(); SqlCommand cmd = new SqlCommand("select Menu from tbl_Content where Menu='" + p.Menu + "'", con); SqlDataAdapter da = new SqlDataAdapter(cmd); da.Fill(ds); if (ds.Tables[0].Rows.Count > 0) { check = Convert.ToInt32(ds.Tables[0].Rows[0]["Menu"].ToString()); } if (check != 1 && check != 2 && check != 3) { try { string fileLocation = ""; string ThumbfileLocation = ""; string ItemUploadFolderPath = "~/DataImages/Content/"; string ThumbItemUploadFolderPath = "~/DataImages/Content/Thumbnail/"; foreach (string item in Request.Files) { HttpPostedFileBase file = Request.Files[item] as HttpPostedFileBase; if (file.ContentLength == 0) { continue; } if (file.ContentLength > 0) { fileLocation = HelperFunctions.renameUploadFile(file, ItemUploadFolderPath); ThumbfileLocation = HelperFunctions.ThumbrenameUploadFile(file, ThumbItemUploadFolderPath, 1); //Thumbnail } } if (fileLocation == "") { fileLocation = ""; ThumbfileLocation = ""; } p.id = "0"; if (p.Menu == null) { p.Menu = ""; } if (p.SubMenu == null) { p.SubMenu = ""; } if (p.SubMenuLevel2 == null) { p.SubMenuLevel2 = ""; } if (p.ThumbImgURL == null) { p.ThumbImgURL = ""; } if (p.ImgURL == null) { p.ImgURL = ""; } if (p.Title == null) { p.Title = ""; } if (p.URLTitle == null) { p.URLTitle = ""; } p.ImgURL = fileLocation; p.ThumbImgURL = ThumbfileLocation; if (dl.INSERT_UPDATE_CONTENT(p) > 0) { TempData["MSG"] = "Record Saved Successfully!!"; ModelState.Clear(); } else { TempData["MSG"] = "Record not Saved"; } } catch (Exception ex) { TempData["MSG"] = ex.ToString(); } } else { TempData["MSG"] = "You Have Already Insert Content In About Or Our Creation Or Contact Or Logo Or Head Social Section Please Go For Only Update.."; } ListMenu(); return(View()); }