public async Task<ActionResult> Index(List<JobHistoryModel> model) { if (ModelState.IsValid) { bool historyStored = false; using (var client = new DataServiceClient()) { client.Open(); var history = new List<JobHistory>(); foreach (var jobHistory in model) { int tempYear; int tempMonth; var jobHist = new JobHistory(); jobHist.street = jobHistory.street; jobHist.city = jobHistory.city; jobHist.stateAbrev = jobHistory.state; jobHist.zip = jobHistory.zip; jobHist.applicantId = Convert.ToInt32(this.Session["ApplicantId"]); jobHist.duties = jobHistory.responsibilities; jobHist.employer = jobHistory.employer; jobHist.endSalary = jobHistory.salary_end; jobHist.startSalary = jobHistory.salary_start; if (jobHistory.from_year != null && jobHistory.from_month != null) { tempYear = Convert.ToInt32(jobHistory.from_year); tempMonth = Convert.ToInt32(jobHistory.from_month); jobHist.fromDate = new DateTime(tempYear, tempMonth, 1); tempYear = Convert.ToInt32(jobHistory.to_year); tempMonth = Convert.ToInt32(jobHistory.to_month); jobHist.toDate = new DateTime(tempYear, tempMonth, 1); } else { jobHist.toDate = null; jobHist.fromDate = null; } jobHist.phone = jobHistory.phone; jobHist.position = jobHistory.position; jobHist.reasonLeave = jobHistory.reason_for_leaving; jobHist.supervisor = jobHistory.supervisor; jobHist.applicantId = jobHistory.applicantId; jobHist.jobHistoryId = jobHistory.historyId; history.Add(jobHist); } historyStored = await client.updateJobHistoryAsync(history.ToArray()); client.Close(); } if (historyStored/**true**/) { this.Session["JobHistory"] = "Done"; return RedirectToAction("Index", "Education"); } else { //error in storing history... add error view or determine action?? } } return View(model); }