public JobSeeker() { ResumeAttachment = new Attachment(); }
public ActionResult JobSeekers(JobSeekerModel jobSeekerModel, HttpPostedFileBase resumeAttachment) { var result = GetUgQualifications(); result.Sort(); ViewData["UGQualifications"] = result; result = GetPgQualifications(); result.Sort(); ViewData["PGQualifications"] = result; result = GetIndustries(); result.Sort(); ViewData["Industries"] = result; result = GetFunctionalAreas(); result.Sort(); ViewData["FunctionalArea"] = result; string selectedGender = string.Empty; if (Request.Form["Gender"] != null) selectedGender = Request.Form["Gender"]; string selectedUgQualification = string.Empty; if (Request.Form["UGQualification"] != null) selectedUgQualification = Request.Form["UGQualification"]; string selectedPgQualification = string.Empty; if (Request.Form["PGQualification"] != null) selectedPgQualification = Request.Form["PGQualification"]; string selectedIndustry = string.Empty; if (Request.Form["Industry"] != null) selectedIndustry = Request.Form["Industry"]; string selectedFunctionalArea = string.Empty; if (Request.Form["Functional"] != null) selectedFunctionalArea = Request.Form["Functional"]; if (string.IsNullOrEmpty(selectedGender)) ModelState.AddModelError("Gender", "Please select gender."); if (string.IsNullOrEmpty(selectedUgQualification)) ModelState.AddModelError("UgQualification", "Please select your ug qualification."); else if (selectedUgQualification.ToLower().Trim() == "others" && string.IsNullOrEmpty(jobSeekerModel.UgOthers)) { ModelState.AddModelError("UgOthers", "Please input your ug qualification - others"); } if (string.IsNullOrEmpty(selectedPgQualification)) ModelState.AddModelError("PgQualification", "Please select your pg qualification."); else if (selectedPgQualification.ToLower().Trim() == "others" && string.IsNullOrEmpty(jobSeekerModel.PgOthers)) { ModelState.AddModelError("PgOthers", "Please input your pg qualification - others"); } if (string.IsNullOrEmpty(selectedIndustry)) ModelState.AddModelError("Industry", "Please select industry."); else if (selectedIndustry.ToLower().Trim() == "others" && string.IsNullOrEmpty(jobSeekerModel.IndustryOthers)) { ModelState.AddModelError("IndustryOthers", "Please input your industry - others"); } if (string.IsNullOrEmpty(selectedFunctionalArea)) ModelState.AddModelError("Functional", "Please select your functional area."); else if (selectedFunctionalArea.ToLower().Trim() == "others" && string.IsNullOrEmpty(jobSeekerModel.FunctionalOthers)) { ModelState.AddModelError("FunctionalOthers", "Please input your functiona area - others"); } if (ModelState.IsValid) { var scope = ObjectScopeProvider1.GetNewObjectScope(); scope.Transaction.Begin(); var jobSeeker = new JobSeeker { CurrentCtc = jobSeekerModel.CurrentCtc, DateOfBirth = jobSeekerModel.DateOfBirth, EmailID = jobSeekerModel.EmailID, ExpectedCtc = jobSeekerModel.ExpectedCtc, FirstName = jobSeekerModel.FirstName, Functional = jobSeekerModel.Functional, FunctionalOthers = jobSeekerModel.FunctionalOthers, Gender = jobSeekerModel.Gender, Industry = jobSeekerModel.Industry, IndustryOthers = jobSeekerModel.IndustryOthers, LastName = jobSeekerModel.LastName, MobileNo = jobSeekerModel.MobileNo, NoticePeriod = jobSeekerModel.NoticePeriod, OptionalEmailID = jobSeekerModel.OptionalEmailID, PgOthers = jobSeekerModel.PgOthers, PgQualification = jobSeekerModel.PgQualification, PhoneNo = jobSeekerModel.PhoneNo, PrimarySkillSet = jobSeekerModel.PrimarySkillSet, RelaventExperience = jobSeekerModel.RelaventExperience, SecondarySkillSet = jobSeekerModel.SecondarySkillSet, TotalExperience = jobSeekerModel.TotalExperience, UgOthers = jobSeekerModel.UgOthers, UgQualification = jobSeekerModel.UgQualification }; Stream fileStream = resumeAttachment.InputStream; int fileLength = resumeAttachment.ContentLength; var attachment = new Attachment { Filedata = new byte[fileLength], MimeType = resumeAttachment.ContentType, Id = DateTime.Now.Ticks.ToString() }; fileStream.Read(attachment.Filedata, 0, fileLength); jobSeeker.ResumeAttachment = attachment; scope.Add((jobSeeker)); scope.Transaction.Commit(); ViewData["Status"] = "Thank you for uploading your profile, we will get back to you soon."; return View("Status"); } ViewData["Selectedgender"] = selectedGender; ViewData["SelectedUgQualification"] = selectedUgQualification; ViewData["SelectedPgQualification"] = selectedPgQualification; ViewData["SelectedIndustry"] = selectedIndustry; ViewData["SelectedFunctionalArea"] = selectedFunctionalArea; return View(); }