public ActionResult saveSurveyForm(string id) { string fieldNames = "Reference_Number"; string values = "'" + id + "'"; string setString = "Reference_Number='" + id + "'"; SurveyEntities _dbContext = new SurveyEntities(); foreach (string key in Request.Form.Keys) { fieldNames += "," + key; values += "," + "'" + Request.Form[key] + "'"; setString += "," + key + "='" + Request.Form[key] + "'"; } var data = _dbContext.submitFormData(id, "", fieldNames, values, setString); return RedirectToAction("TeamLeadListing"); }
public ActionResult submitSurveyForm(string id) { string fieldNames = "Reference_Number"; string values = "'" + id + "'"; string setString = "Reference_Number='" + id + "'"; SurveyEntities _dbContext = new SurveyEntities(); foreach (string key in Request.Form.Keys) { fieldNames += "," + key; values += "," + "'" + Request.Form[key] + "'"; setString += "," + key + "='" + Request.Form[key] + "'"; } var data = _dbContext.submitFormData(id, "", fieldNames, values, setString); if (Request.Files.Count > 0) { for (int i = 0; i < Request.Files.Count; i++) { var postedFile = Request.Files[i]; if (String.IsNullOrEmpty(postedFile.FileName)) continue; string folderpath = Server.MapPath("~/Images/SurveyForms/" + id.ToString()); if (!Directory.Exists(folderpath)) { Directory.CreateDirectory(folderpath); } var filePath = folderpath + "/" + postedFile.FileName; postedFile.SaveAs(filePath); } } return RedirectToAction("SurveyListing"); }