private void SetPatientsOnModel(BiopsyCreateModel model) { model.Patients = (_patientStore.GetPatients()).Select(p => new SelectListItem() { Text = p.Id, Value = p.Id }); }
// GET: /Biopsy/Create public ActionResult Create() { var model = new BiopsyCreateModel(); SetPatientsOnModel(model); return(View(model)); }
public async Task <ActionResult> Create([Bind(Include = "Id,PatientId")] BiopsyCreateModel biopsyModel) { if (ModelState.IsValid) { var biopsy = new Biopsy() { Id = biopsyModel.Id, PatientId = biopsyModel.PatientId }; await _biopsyStore.AddBiopsyAsync(biopsy); return(RedirectToAction("Index")); } SetPatientsOnModel(biopsyModel); return(View(biopsyModel)); }