private void LoadAllTest() { List <Title> titles = servObj.LoadAllTitle().ToList(); foreach (var item in titles) { TestTitle.Add(item.Title1); } }
private void SetTestTitleId(TestTitle testTitle, long testTitleId) { testTitle.TestAnswers.ForEach(a => { a.TestTitleId = testTitleId; }); testTitle.TestOptions.ForEach(a => { a.TestTitleId = testTitleId; }); }
private void InitCommand() { BackCmd = new RelayCommand(() => { if (TestType != null || SelectedPriority != 0 || TestSpecimenCode != null || SelectedTitle != null) { MessageBoxResult msgResult = MessageBox.Show("Are you sure to back?", "Confirmation", MessageBoxButton.YesNo, MessageBoxImage.Question); if (msgResult == MessageBoxResult.Yes) { TestType = SelectedTitle = TestSpecimenCode = null; SelectedPriority = TestOrderNumber = 0; navigationService.NavigateTo(ViewModelLocator.PatientKey); } } else { navigationService.GoBack(); } }); AddTestCmd = new RelayCommand(() => { if (ViewModelLocator.OrderNumberViewModel != 0) { TestModel testModel = new TestModel(SelectedTitle, TestType, 0, TestSpecimenCode, SelectedPriority, false, TestOrderNumber); ViewModelLocator.TestModelList.Add(testModel); //servObj.CreateTestData(ConverterDataBase.toDataBase(testModel)); TestType = SelectedTitle = TestSpecimenCode = null; SelectedPriority = TestOrderNumber = 0; navigationService.GoBack(); } }); OnLoad = new RelayCommand(() => { TestTitle.Clear(); LoadAllTest(); if (ViewModelLocator.OrderNumberViewModel != 0) { TestOrderNumber = ViewModelLocator.OrderNumberViewModel; } else { TestOrderNumber = servObj.NextIdOrder(); } }); }
public ActionResult SaveTestTitle(TestTitle testTitle) { if (!ModelState.IsValid) { return(View("TestTitleForm", testTitle)); } else if (testTitle.Id == 0) { _context.TestTitles.Add(testTitle); } else { var TestTitleinDb = _context.TestTitles.Single(t => t.Id == testTitle.Id); TestTitleinDb.Name = testTitle.Name; TestTitleinDb.Notes = testTitle.Notes; TestTitleinDb.Price = testTitle.Price; } _context.SaveChanges(); return(RedirectToAction("Index")); }