public int CreateTestSession(UserTestModel userAndTest) { var result = DefaultErrorCode; using (var connection = factory.CreateConnection()) { connection.ConnectionString = connectionString; var command = connection.CreateCommand(); command.CommandText = "[TestInfo].[CreateTestSession]"; command.CommandType = CommandType.StoredProcedure; var testIdParam = command.CreateParameter(); testIdParam.ParameterName = "@TestID"; testIdParam.DbType = DbType.Int32; testIdParam.Value = userAndTest.TestID; var userIdParam = command.CreateParameter(); userIdParam.ParameterName = "@UserID"; userIdParam.DbType = DbType.Int32; userIdParam.Value = userAndTest.UserID; command.Parameters.AddRange(new[] { testIdParam, userIdParam }); connection.Open(); result = (int)command.ExecuteScalar(); } return(result); }
public UserTestModel Add(UserTestModel userTestModel) { UserTestModel model; try { if (userTestModel is null) { throw new ArgumentNullException(nameof(userTestModel)); } var teacher = _uow.Repository <UserModel>() .GetQueryable() .FirstOrDefault(u => u.Id == CurrentUser.Instance.Id); userTestModel.UserModel = teacher; model = _uow.Repository <UserTestModel>().Add(userTestModel); _uow.SaveChanges(); } catch (Exception e) { Debug.WriteLine(e); throw; } return(model); }
public TestListViewModel(ITestListService testListService) { Tests = new ObservableCollection <TestListModel>( UserTestModel.ToTaskList(testListService.GetListByTeacher())); // TODO: FIX ME //RedirectDecorator.ToViewModel(typeof(MainWindowViewModel)); //MessageError.TeacherNotFound.Show(); }
public static void AssertFakeUserDetails(UserTestModel testUser) { using (new AssertionScope()) { testUser.Should().NotBeNull(); testUser.LastName.Should().NotBeNullOrEmpty(); testUser.FirstName.Should().NotBeNullOrEmpty(); testUser.Email.Should().NotBeNullOrEmpty(); testUser.Password.Should().NotBeNullOrEmpty(); } }
public TestResultViewModel(ITestResultService testResultService) { _testResultService = testResultService; _userTestModel = TinyTempCache.Get <Type, UserTestModel>(typeof(UserTestModel)); _testResults = _testResultService.GetResults(new TestKey { UnitName = _userTestModel.UnitName, LessonName = _userTestModel.LessonName }); }
public List <TestSessionModel> GetUserTestSessions(UserTestModel userAndTest) { var sessions = new List <TestSessionModel>(); using (var connection = factory.CreateConnection()) { connection.ConnectionString = connectionString; var command = connection.CreateCommand(); command.CommandText = "[TestInfo].[GetUserTestSessions]"; command.CommandType = CommandType.StoredProcedure; var testIdParam = command.CreateParameter(); testIdParam.ParameterName = "@TestID"; testIdParam.DbType = DbType.Int32; testIdParam.Value = userAndTest.TestID; var userIdParam = command.CreateParameter(); userIdParam.ParameterName = "@UserID"; userIdParam.DbType = DbType.Int32; userIdParam.Value = userAndTest.UserID; command.Parameters.AddRange(new[] { testIdParam, userIdParam }); connection.Open(); using (IDataReader reader = command.ExecuteReader()) { while (reader.Read()) { var session = new TestSessionModel { TestSessionID = (int)reader["TestSessionID"], TestID = (int)reader["TestID"], UserID = (int)reader["UserID"], BeginTime = (DateTime)reader["BeginTime"], EndTime = (DateTime)reader["EndTime"], QuestionsCount = (int)reader["QuestionsCount"], RightAnswers = (int)reader["RightAnswers"], }; if (!reader.IsDBNull(reader.GetOrdinal("Time"))) { session.Time = (DateTime)reader["Time"]; } sessions.Add(session); } } } return(sessions); }
public IActionResult PostUserTest(UserTestModel userTest) { try { _userTestService.CreateUserTest(mapper.Map <UserTestModel, UserTestDTO>(userTest)); } catch (ValidationException ex) { return(BadRequest(ex.Message)); } catch (Exception) { return(StatusCode(500)); } return(Ok(new { Message = "Result of test was successfully created!" })); }
public StartedTestViewModel(ITestService testService, ITestResultService testResultService) { _answers = new Dictionary <string, ICollection <string> >(); _testKey = TinyTempCache.Get <Type, TestKey>(typeof(TestKey)); _testService = testService; _testResultService = testResultService; _userTestModel = _testService.GetTestByTaskDescriptionWithPermution(_testKey); _timer = _userTestModel.Duration; NextQuestion = new RelayCommand(ShowNextQuestion); TestResult = new RelayCommand(ShowTestResult); Back = new RelayCommand(ShowBack); Reset(); StartTimer(); }
public IActionResult PutUserTest(UserTestModel userTest) { try { _userTestService.UpdateUserTest(mapper.Map <UserTestModel, UserTestDTO>(userTest)); } catch (ValidationException ex) { return(BadRequest(ex.Message)); } catch (NotFoundException ex) { return(NotFound(ex.Message)); } catch (Exception) { return(StatusCode(500)); } return(Ok(new { Message = "UserTest was successfully changed!" })); }
/// <summary> /// Generates user with random email and password /// </summary> public UserBuilder() { this.newUser = GenerateRequiredUserData(); }