public ActionResult WantJob(WantJobList JobList, FormCollection FormPost) { var User = (DAL.UserInfo)Session["NewUser"]; string SelectStr = FormPost["subject-select"]; if (SelectStr != "") { try { string[] SelectResult = SelectStr.Substring(0, SelectStr.Length - 1).Split(','); string NewWorkerId = User.UserID; for (int i = 0; i < SelectResult.Count(); i++) { DAL.WantJob WorkerWant = new WantJob(); WorkerWant.ID = BLL.BaseUtility.GenerateGUID(); WorkerWant.SubjectsID = Convert.ToInt32(SelectResult[i]); WorkerWant.WorkerID = NewWorkerId; DbEntities.WantJob.AddObject(WorkerWant); DbEntities.SaveChanges(); } return RedirectToAction("VerifyEmail", "Account"); } catch { ModelState.AddModelError("", "failed, please try again."); return View(JobList); } } else { return RedirectToAction("VerifyEmail", "Account"); } }
public ActionResult WantJob() { if (Session["NewUser"] != null) { WantJobList JobList = new WantJobList(); JobList.WantList = new List<WantJobModel>(); UI.Utility.WantJob WantJobCulture = new Utility.WantJob(); var SubjectParent = DbEntities.Subjects.Where(p => p.ParentId == null); foreach (var TempParent in SubjectParent) { WantJobModel WantJob = new WantJobModel(); WantJob.SubjectsList = new List<Subjects>(); WantJob.ID = TempParent.ID; //WantJob.Name = TempParent.Name; WantJob.Name = WantJobCulture.GetItem(TempParent.ID); var SubjectSub = DbEntities.Subjects.Where(p => p.ParentId == TempParent.ID); foreach (var TempSub in SubjectSub) { Subjects TempSubject = new Subjects(); TempSubject.ID = TempSub.ID; TempSubject.Name = WantJobCulture.GetItem(TempSub.ID); TempSubject.ParentId = TempSub.ParentId; WantJob.SubjectsList.Add(TempSubject); } JobList.WantList.Add(WantJob); } return View(JobList); } else { return RedirectToAction("LogIn", "Account"); } }