public static string AddCandidate_Query(CandidateClass candidate) { string sql = "INSERT INTO dbo.Candidate (Name,PhoneNumber,Email,resume,interviewdatetime) Output Inserted.TempId VALUES " + " ('" + candidate.name + "','" + candidate.phoneNumber + "','" + candidate.email + "','" + candidate.FileName + "','" + candidate.CreatedDate + "')"; return(sql); }
public ActionResult AddCandidate(HttpPostedFileBase file_Uploader, FormCollection frm, int ReqId) { if (file_Uploader != null) { int TempId; DBManager db = new DBManager(); ViewBag.ReqId = ReqId; CandidateClass uploadFileModel = new CandidateClass(); uploadFileModel.name = frm["name"]; uploadFileModel.email = frm["email"]; uploadFileModel.phoneNumber = Convert.ToInt64(frm["PhoneNumber"]); uploadFileModel.CreatedDate = Convert.ToDateTime(frm["CreatedDate"].ToString()); string fileName = string.Empty; string destinationPath = string.Empty; string Path1 = ConfigurationManager.AppSettings["FilePath"].ToString(); fileName = Path.GetFileName(file_Uploader.FileName); //string name = fileName.Substring(0, fileName.LastIndexOf(".")); string extn = fileName.Substring(fileName.LastIndexOf(".")); fileName = "Resume" + "_" + uploadFileModel.name + "_" + (Environment.TickCount & Int32.MaxValue) + extn; uploadFileModel.FileName = fileName; destinationPath = Path.Combine(Path1, fileName); TempId = db.AddCandidate(uploadFileModel); int i = db.RequestedCandidates(ReqId, TempId); file_Uploader.SaveAs(destinationPath); if (i > 1) { ViewBag.Status = "Submitted !"; } } return(RedirectToAction("GetCandidates", "Candidate", new { ReqId = ReqId })); }
public ActionResult FileUpload(HttpPostedFileBase file_Uploader, FormCollection frm) { if (file_Uploader != null) { DBManager db = new DBManager(); CandidateClass uploadFileModel = new CandidateClass(); uploadFileModel.name = frm["name"]; uploadFileModel.email = frm["email"]; uploadFileModel.phoneNumber = Convert.ToInt64(frm["PhoneNumber"]); string fileName = string.Empty; string destinationPath = string.Empty; string Path1 = ConfigurationManager.AppSettings["FilePath"].ToString(); fileName = Path.GetFileName(file_Uploader.FileName); //string name = fileName.Substring(0, fileName.LastIndexOf(".")); string extn = fileName.Substring(fileName.LastIndexOf(".")); fileName = "Resume" + "_" + uploadFileModel.name + "_" + (Environment.TickCount & Int32.MaxValue) + extn; uploadFileModel.FileName = fileName; destinationPath = Path.Combine(Path1, fileName); db.AddCandidate(uploadFileModel); file_Uploader.SaveAs(destinationPath); } return(View()); }