public ActionResult Create(TreatmentType type) { try { if (ModelState.IsValid) { service.TreatmentTypeGateway.CreateOne(type); return RedirectToAction("Index"); } return View(type); } catch { return View(); } }
private IEnumerable<SelectListItem> GetTypes(TreatmentType type) { List<SelectListItem> treatmentTypeSelectList = new List<SelectListItem>(); foreach (TreatmentType treatmentType in service.TreatmentTypeGateway.GetAll()) { treatmentTypeSelectList.Add(new SelectListItem { Text = treatmentType.Name, Value = treatmentType.Id.ToString(), Selected = (type.Id == treatmentType.Id) }); } return treatmentTypeSelectList; }