protected override void beforeEach() { var model = new TestInputModel { PropInt = 99 }; _flash.Flash(model); }
public async Task <ResponseOutput> AddTest(TestInputModel testInput) { if (testInput == null) { return(new ResponseOutput { Success = false, Message = "Object null" }); } var response = new ResponseOutput(); try { var test = new Tests { Id = 0, Title = testInput.Title, TypeId = testInput.Type }; var questions = new List <Qtions>(); foreach (var qtion in testInput.Questions) { var temp = new Qtions { Id = 0, ContentQ = qtion.ContentQ, Answer1 = qtion.Answer1, Answer2 = qtion.Answer2, Answer3 = qtion.Answer3, Answer4 = qtion.Answer4, Part = qtion.Part, TopicId = qtion.TopicId }; questions.Add(temp); } await _repository.InsertAsync(test); await UnitOfWork.SaveChangesAsync(); _questionRepo.InsertRange(questions); await UnitOfWork.SaveChangesAsync(); response.Success = true; // await InsertParagraphs(testInput.Paragraphs); } catch (Exception ex) { response.Success = false; response.Message = ex.Message; } return(response); }
public async Task <IActionResult> AddTest(int projectId, int userStoryId) { var testInputModel = new TestInputModel() { UserStoryId = userStoryId, UserStoryDropDown = await this.userStoryService.GetUserStoryDropDownsAsync(projectId), }; return(View(testInputModel)); }
public PageModel<TestOutputModel> ListPage(TestInputModel model) { string sql = @"SELECT *,NewID() AS OrganizationID FROM [dbo].[TestTable] WHERE [Name] like '%'+@Name+'%' "; string orderBy = "ORDER BY [Name] DESC"; Collection<IDataParameter> parms = new Collection<IDataParameter>(); parms.Add(new SqlParameter("@Name", "test")); return base.ListPage(sql, model.PageNO ?? 1, model.PageSize ?? 10, parms, orderBy); }
public TestDTO ConvertTestInputModelToTestDTO(TestInputModel testmodel) { return(new TestDTO() { ID = testmodel.ID, Name = testmodel.Name, DurationTime = TimeSpan.Parse(testmodel.DurationTime), SuccessScore = testmodel.SuccessScore, QuestionNumber = testmodel.QuestionNumber, }); }
public void YearAndEgnShouldReturnErrorWhenDontMatch() { var viewModel = new TestInputModel { DateOfBirth = new DateTime(1912, 1, 1), Egn = "1134567890", }; var errors = viewModel.Validate(null).Count(); Assert.Equal(1, errors); }
public ActionResult AddTest(int id, TestInputModel model) { if (!this.ModelState.IsValid) { return this.View(model); } // Maaaagic :) var mapp = this.Mapper.Map<Test>(model); this.testService.Create(mapp, id); return this.RedirectToAction("Details", "Courses", new { id = id, area = "Public" }); }
public void SetUp() { _uow = MockRepository.GenerateMock <IUnitOfWork>(); _insideBehavior = MockRepository.GenerateStub <IControllerActionBehavior>(); _behavior = new access_the_database_through_a_unit_of_work(_uow) { InsideBehavior = _insideBehavior }; _input = new TestInputModel(); _output = new TestOutputModel(); _actionFunc = i => new TestOutputModel(); }
public BaseResultModel <TestOutputModel> CreateData(TestInputModel model) { try { var result = new SuccessResultModel <TestOutputModel>(); result.Data = this.TestTableRepository.InsertAndReturn(model); return(result); } catch (Exception e) { LogWriter.WriteLog(EnumLogLevel.Fatal, "ListData", "", "", "创建数据时发生错误.", e); return(new ErrorResultModel <TestOutputModel>("", "创建数据时发生错误")); } }
public ActionResult <int> PostTest(TestInputModel testModel) { if (string.IsNullOrWhiteSpace(testModel.Name)) { return(BadRequest("Введите название теста")); } if (string.IsNullOrWhiteSpace(testModel.DurationTime)) { return(BadRequest("Введите время прохождения теста")); } if (testModel.QuestionNumber == null) { return(BadRequest("Введите количество вопросов в тесте")); } if (testModel.SuccessScore == null) { return(BadRequest("Введите минимальный балл для прохождения теста")); } Mapper mapper = new Mapper(); TestDTO testDto = mapper.ConvertTestInputModelToTestDTO(testModel); AuthorDataAccess test = new AuthorDataAccess(); return(Ok(test.AddTest(testDto))); }
/// <summary> /// 测试用例 /// </summary> /// <param name="model"></param> /// <returns></returns> public BaseResultModel <List <TestOutputModel> > Test(TestInputModel model) { try { List <TestOutputModel> result; result = this.TestTableRepository.List().ToList(); //增 this.TestTableRepository.Insert(model); var insertresult = this.TestTableRepository.InsertAndReturn(model); List <TestInputModel> list = new List <TestInputModel>(); list.Add(model); list.Add(model); this.TestTableRepository.InsertCol(list.ToArray()); using (this.TestTableRepository.BeginLikeMode()) {// using里使用like查询 PageModel <TestOutputModel> m1 = this.TestTableRepository.ListPage(model); } //不模糊查询 PageModel <TestOutputModel> m = this.TestTableRepository.ListPage(model); using (this.TestTableRepository.BeginLikeMode()) {// using里使用like查询 //查 result = this.TestTableRepository.List(model).ToList(); model = new TestInputModel(); var pageresult = this.TestTableRepository.ListPage(model).ListData.ToList(); var mymodel = this.TestTableRepository.SelectWithModel(model); mymodel.Name = "test2"; //改 this.TestTableRepository.UpdateWithKeys(mymodel); var mymodel2 = this.TestTableRepository.SelectWithKeys(mymodel); model.Name = "test2"; mymodel = new TestOutputModel(); mymodel.Name = "test3"; var listUpdateModel = this.TestTableRepository.UpdateWithModelAndReturn(mymodel, model); mymodel2 = this.TestTableRepository.SelectWithKeys(mymodel); } // 删 model.Timestamp = new byte[0]; var i = this.TestTableRepository.DeleteWithModel(model); this.TestTableRepository.SelectWithModel(model); i = this.TestTableRepository.DeleteWithIdentity(1); this.TestTableRepository.Search(model, true); this.TestTableRepository.UpdateWithModel(model, model); i = this.TestTableRepository.DeleteWithKeys( new TestInputModel() { ID = new Guid("F68AA6B5-7BA2-456E-85D7-BE31791B3FDF") } ); TransactionOptions option = new TransactionOptions(); option.IsolationLevel = IsolationLevel.ReadCommitted; using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, option)) { model.ID = new Guid("A317E4B2-A8C4-4E35-89A0-22A1F515E281"); this.TestTableRepository.Insert(model); scope.Complete(); } this.TestTableRepository.TruncateTable(); //夸数据库事务 using (TransactionScope scope = new TransactionScope(TransactionScopeOption.RequiresNew)) { this.TestTable44Repository.InsertCol(list.ToArray()); scope.Complete(); } return(new SuccessResultModel <List <TestOutputModel> >(null)); } catch (Exception e) { LogWriter.WriteLog(EnumLogLevel.Fatal, "ListData", "", "", "查询数据时发生错误.", e); return(new ErrorResultModel <List <TestOutputModel> >("", "查询数据时发生错误")); } }
public ActionResult MakeTest(int id, TestInputModel model) { var result = this.RedirectToAction("MakeTest", new { id = id }); if (!this.ModelState.IsValid) { this.TempData["Message"] = "Please check test form again!"; return result; } var test = this.courseService.GetAll() .FirstOrDefault(c => c.Id == id) .Tests .FirstOrDefault(t => t.Id == model.TestId); if (test.Questions.Count != model.Questions.Count) { this.TempData["Message"] = "Fill all questions"; return result; } var testResult = this.courseService.SolveTest(id, this.UserId, model.TestId, model.Questions); return this.RedirectToAction("TestResult", "Courses", new { id = testResult.Id, area = "Public" }); }
public TestViewModel GetOther(TestInputModel input) { return(new TestViewModel()); }
public TestViewModel GetIndex(TestInputModel input) { return(new TestViewModel()); }
public async Task <ResponseOutput> AddTest([FromBody] TestInputModel test) { return(await _service.AddTest(test)); }
public IActionResult InputModel([FromQuery] TestInputModel input) { return(Json(input)); }