public ActionResult PatientSelect(string dfn) { PatientEducationSelect model = new PatientEducationSelect(); model.Patient = this.CurrentPatient; EducationItemsResult result = this.DashboardRepository.Education.GetEducationItems("", "", EducationItemType.Unknown, 0, 0, EducationItemSort.Type); if (!result.Success) { this.Error(result.Message); } else if (result.EducationItems != null) { if (result.EducationItems.Count > 0) { result.EducationItems.Sort(delegate(EducationItem x, EducationItem y) { int returnVal = 0; if (x.Category == y.Category) { returnVal = x.Description.CompareTo(y.Description); } else { returnVal = x.Category.CompareTo(y.Category); } return(returnVal); }); string currentCategory = ""; foreach (EducationItem item in result.EducationItems) { if (item.Category != currentCategory) { PatientEducationSelectItemRow catRow = new PatientEducationSelectItemRow() { CategoryRow = true, Category = item.Category }; model.AddRow(catRow); currentCategory = item.Category; } PatientEducationSelectItemRow itemRow = new PatientEducationSelectItemRow() { Ien = item.Ien, ItemType = item.ItemType, ItemTypeDescription = item.ItemTypeDescription, Description = item.Description, Category = item.Category }; model.AddRow(itemRow); } } } return(View(model)); }
public ActionResult PatientSelect(PatientEducationSelect model) { ActionResult returnResult; List <string> ienList = model.GetSelectedIenList(); bool ok = false; if (ienList != null) { foreach (string ien in ienList) { PatientEducationItem patItem = new PatientEducationItem(); patItem.EducationItemIen = ien; patItem.PatientDfn = model.Patient.Dfn; patItem.CompletedOn = DateTime.Now; IenResult ienResult = this.DashboardRepository.Education.SavePatientItem(patItem); if (!ienResult.Success) { this.Error(ienResult.Message); ok = false; break; } else { ok = true; } } } if (ok) { this.Information("Education Items Added Successfully"); returnResult = RedirectToAction("PatientIndex", new { dfn = model.Patient.Dfn }); } else { this.CurrentPatientDfn = model.Patient.Dfn; model.Patient = this.CurrentPatient; returnResult = View(model); } return(returnResult); }