public TestBusiness GetTestById(int testId) { Repo = new TestRepository(); Test test = null; try { test = Repo.GetTest(testId); } catch (NullReferenceException ex) { throw; } catch (InvalidOperationException ex) { //TODO } catch (Exception ex) { //TODO } TestBusiness testBusiness = TestMapper.MapDalToBiz(test); return(testBusiness); }
public ActionResult Index() { TestBusiness tobj = new TestBusiness(); tobj.InitializeDB(); return(View()); }
public IActionResult DeleteTest(int id) { var test = TestBusiness.GetTest(id); TestBusiness.DeleteTest(test); return(RedirectToAction("Index")); }
public void TestMethodSaveChangesDB_ERR() { TestBusiness test = new TestBusiness() { Date = DateTime.Now, UserId = 1 }; QuestionBusiness question = new QuestionBusiness() { TestId = 1, }; AnswerBusiness answer = new AnswerBusiness() { IsCorrect = true, QuestionId = 1, Score = 10, }; TestService testService = new TestService(); try { question.Answers.Add(answer); test.Questions.Add(question); testService.AddNewTest(test); } catch (Exception ex) { int g = 0; } }
public IActionResult Index() { var model = new TestViewModel { TestList = TestBusiness.GetTestList(Convert.ToInt32(HttpContext.Session.GetInt32("userId"))) }; return(View(model)); }
public PrintReport() { InitializeComponent(); test = new TestBusiness(); this.grideMes.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; this.grideMes.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; this.grideMes.AllowUserToAddRows = false; }
public TestDto(TestBusiness test) { Id = test.Id; URL = test.URL; Date = test.Date; UserId = test.UserId; Questions = test.Questions?.Select(q => new QuestionDto(q)).ToList(); AdministratedTests = test.AdministratedTests?.Select(t => new AdministratedTestDto(t)).ToList(); }
public IActionResult SolveTest(int id) { var test = TestBusiness.GetTest(id); List <Question> questions = QuestionBusiness.GetTestQuestion(id); var model = new TestViewModel { QuestionList = questions, Test = test }; return(View(model)); }
public void AddNewTest(TestBusiness test) { using (TestRepository _repo = new TestRepository()) { if (string.IsNullOrWhiteSpace(test.URL)) { throw new Exception("Test not saved"); } _repo.SaveTest(TestMapper.MapBizToDal(test)); } }
public void UpdateTest(TestBusiness test) { using (TestRepository _repo = new TestRepository()) { if (string.IsNullOrWhiteSpace(test.URL)) { throw new Exception("Test not saved"); } _repo.UpdateTest(test); } }
private TestBusiness MapDalToBizLigth2(TestBusiness test) { var returned = new TestBusiness { Id = test.Id, URL = test.URL, Date = test.Date, UserId = test.UserId, }; return(returned); }
public ActionResult EditQuestion_Get(QuestionDto question) { TestBusiness questionRelatedTest = _service.GetTestById(question.TestId); QuestionDto questionToEdit = new QuestionDto(questionRelatedTest.Questions.FirstOrDefault(q => q.Id == question.Id)); questionToEdit.CorrectAnswerScore = question.CorrectAnswerScore; TestModel questionToUpdate = new TestModel(questionToEdit); return(View(questionToUpdate)); }
public static TestBusiness MapDalToBizLigth(Test test) { var returned = new TestBusiness { Id = test.Id, URL = test.URL, Date = test.Date, UserId = test.UserId, Questions = test.Questions.Select(QuestionMapper.MapDalToBiz).ToList() }; return(returned); }
public RecordTestInfomation(string userAcount) { this.user = userAcount; InitializeComponent(); test = new TestBusiness(); test.Name = user; this.txtCode.KeyDown += new KeyEventHandler(txtCode_KeyDown); for (int i = 0; i < control.Length; i++) { cmbControl.Items.Add(control[i]); } cmbControl.SelectedIndex = 0; }
public IActionResult Index(HomeViewModel model) { string key = Guid.NewGuid().ToString(); Test test = new Test { title = model.title, content = model.content, userId = Convert.ToInt32(HttpContext.Session.GetInt32("userId")), key = key, createdDate = DateTime.Now }; TestBusiness.AddTest(test); Test currentTest = TestBusiness.GetTest(key); QuestionBusiness.SaveQuestions(model.Questions, currentTest); return(RedirectToAction("Index", "Test")); }
public static Test MapBizToDal(TestBusiness test) { var returned = new Test { Id = test.Id, URL = test.URL, Date = test.Date, UserId = test.UserId, //AdministratedTests = test.AdministratedTests.Select(AdministratedTestMapper.MapDomainToDao).ToList(), Questions = test.Questions.Select(QuestionMapper.MapBizToDal).ToList(), }; return(returned); }
public void UpdateTest(TestBusiness test) { if (test == null) { throw new NullReferenceException("No test to update"); } Test mappedTest = TestMapper.MapBizToDal(test); Test testToUpdate = _ctx.Tests.FirstOrDefault(t => t.Id == test.Id); testToUpdate.URL = mappedTest.URL; testToUpdate.User = mappedTest.User; testToUpdate.Date = mappedTest.Date; testToUpdate.UserId = mappedTest.UserId; testToUpdate.AdministratedTests = mappedTest.AdministratedTests; testToUpdate.Questions = mappedTest.Questions; _ctx.SaveChanges(); }
public AdministratedTestBusiness AdministratedTest_Builder(TestBusiness test, string subject) { var newAdTest = new AdministratedTestBusiness(); newAdTest.Date = DateTime.Today; newAdTest.URL = test.URL; newAdTest.TestId = test.Id; newAdTest.TestSubject = subject; newAdTest.AdministratedQuestions = new List <AdministratedQuestionBusiness>(); foreach (var q in test.Questions) { newAdTest.AdministratedQuestions.Add(new AdministratedQuestionBusiness() { Text = q.Text, AdministratedTestId = q.TestId, AdministratedAnswers = q.Answers.Select(a => new AdministratedAnswerBusiness() { Text = a.Text, Score = a.Score, AdministratedQuestionId = a.QuestionId, isCorrect = a.IsCorrect, isSelected = false }).ToList() }); } return(newAdTest); }
public ExampleBusinessTest(TemplateFixture fixture) { _exampleBusiness = fixture.ServiceProvider.GetService <TestBusiness>(); }
/// <summary> /// Constructor /// </summary> /// <param name="example"></param> public TestController(TestBusiness test) { _test = test; }