public ActionResult MBAnalysisEdit( int mbAnalysisId = -1, int sampleId = -1, int patientId = -1, int showRO = -1, int showBac = -1, string message = "", int queue = -1 ) { ViewData["Message"] = message; ViewBag.Queue = queue; vwMBAnaysisEdit model = new vwMBAnaysisEdit(); model.PatientObj = new Patient(); model.SampleObj = new Sample(); model.MBAnalysisObj = new MBAnalysi(); // if (patientId != -1) // { var temp = dbm.MBAnalysis.Include(o => o.Sample).SingleOrDefault(o => o.MBAnalysisID == mbAnalysisId); model.SampleObj = dbm.Samples.SingleOrDefault(o => o.SampleID == temp.SampleID); model.PatientObj = dbm.Patients.SingleOrDefault(o => o.PatientID == temp.Sample.PatientID); model.MBAnalysisObj = db.GetMBAnalysisForSampleSingle(mbAnalysisId); model.listMBAnalysisBacterioscopy = db.GetBacterioscopyForMBAnalysis(mbAnalysisId); model.listRO = db.GetROListforSampleAndMBAnalysis(mbAnalysisId); //} var itemsAnalysis = db.GetMBAnalysisTypeListActive(); List<SelectListItem> listAnalysis = new List<SelectListItem>(); foreach (var item in itemsAnalysis) { listAnalysis.Add(new SelectListItem { Text = item.DescriptionRus, Value = item.MBAnalysisTypeID.ToString() }); } var selectAnalysis = new SelectList(listAnalysis, "Value", "Text", model.MBAnalysisObj.MBAnalysisID); ViewData["selectAnalysis"] = selectAnalysis; var itemsResults = db.GetMBAnalysisResultList(); List<SelectListItem> listResults = new List<SelectListItem>(); foreach (var item in itemsResults) { listResults.Add(new SelectListItem { Text = item.DescriptionRus, Value = item.MBAnalysisResultID.ToString() }); } var selectResults = new SelectList( listResults, "Value", "Text", model.MBAnalysisObj.MBAnalysisResultID.ToString() ); ViewData["selectResults"] = selectResults; var itemsStatus = db.GetMBStatusList(); List<SelectListItem> listStatuses = new List<SelectListItem>(); foreach (var item in itemsStatus) { listStatuses.Add(new SelectListItem { Text = item.DescriptionRus, Value = item.MBStatusID.ToString() }); } var selectStatuses = new SelectList(listStatuses, "Value", "Text", model.MBAnalysisObj.MBStatusID.ToString()); ViewData["selectStatuses"] = selectStatuses; if (showBac > 0) { model.listMBAnalysisBacterioscopy = db.GetBacterioscopyForMBAnalysis(mbAnalysisId); } else { model.listMBAnalysisBacterioscopy = null; } if (showRO > 0) { model.listRO = db.GetROListforSampleAndMBAnalysis(mbAnalysisId); } else { model.listRO = null; } return View(model); }
public ActionResult MBAnalysisEdit(vwMBAnaysisEdit model) { try { MBAnalysi obj = new MBAnalysi(); obj = model.MBAnalysisObj; db.EditMBAnalysis(obj); var tmp = dbm.Samples.SingleOrDefault(o => o.SampleID == model.MBAnalysisObj.SampleID); string strMessage = "Результаты анализа " + model.MBAnalysisObj.MBAnalysisType.DescriptionRus + " для образца " + model.SampleObj.SampleID + " сохранены успешно "; return RedirectToAction("MBAnalysisList", new { message = strMessage, queue = 1 }); } catch (DataException ex) { string strMessage = "Ошибка" + ex.Message + ". Результаты анализа " + model.MBAnalysisObj.MBAnalysisType.DescriptionRus + " для образца " + model.SampleObj.SampleID + " не удалось сохранить "; return RedirectToAction("MBAnalysisList", new { message = strMessage, queue = 1 }); } }