public async Task <int> InsertAthleteInTestAsync(TestDetailsModel testDetailsModel) { var Id = 0; if (!CheckAthleteInTestAsync(testDetailsModel).Result) { try { var cmd = new MySqlCommand(); cmd.CommandText = @"INSERT INTO `testdetails` (`UserId`, `TestId`,`Result`,`IsActive`) VALUES (@UserId, @TestId, @Result, @IsActive);"; cmd.Parameters.Add(new MySqlParameter { ParameterName = "@UserId", DbType = DbType.Int16, Value = testDetailsModel.UserId }); cmd.Parameters.Add(new MySqlParameter { ParameterName = "@TestId", DbType = DbType.Int16, Value = testDetailsModel.TestId }); cmd.Parameters.Add(new MySqlParameter { ParameterName = "@Result", DbType = DbType.Int16, Value = testDetailsModel.Result }); cmd.Parameters.Add(new MySqlParameter { ParameterName = "@IsActive", DbType = DbType.Boolean, Value = testDetailsModel.IsActive }); cmd.Connection = _dbConfig.Connection; _dbConfig.Connection.Open(); await cmd.ExecuteNonQueryAsync(); Id = (int)cmd.LastInsertedId; _dbConfig.Connection.Close(); } catch (Exception ex) { } } return(Id); }
public IActionResult InActiveAthleteInTest([FromBody] TestDetailsModel testDetailsModel) { testDetailsModel.IsActive = false; var output = _atheletService.InactiveAthleteInTest(testDetailsModel).Result; return(Json(output)); }
public async Task <bool> CheckAthleteInTestAsync(TestDetailsModel testDetailsModel) { var isExist = false; try { var cmd = new MySqlCommand(); cmd.CommandText = @"Select * from `testdetails` where TestId = " + testDetailsModel.TestId + " and UserId = " + testDetailsModel.UserId + ";"; cmd.Connection = _dbConfig.Connection; _dbConfig.Connection.Open(); var reader = await cmd.ExecuteReaderAsync(); while (reader.Read()) { isExist = true; } ; _dbConfig.Connection.Close(); } catch (Exception ex) { } return(isExist); }
/// <summary> /// When constructing a test details window, we need a test details model alongside project(repo) info /// so we know where to save updates. /// </summary> /// <param name="detailsModel">The test details model.</param> /// <param name="repository">The project(Repo) info.</param> /// <param name="isReadOnly">Should this not be editable?</param> public TestDetails(TestDetailsModel detailsModel, RepositoryInfo repository, bool isReadOnly = false) { InitializeComponent(); if (isReadOnly) { btnAddTag.IsEnabled = false; btnRunTest.IsEnabled = false; scriptEditor.IsReadOnly = true; txtScriptName.IsReadOnly = true; } _Repository = repository; _TestName = detailsModel.TestName; _TestDetails.Add(new TestDetailsContext(detailsModel)); DataContext = _TestDetails; Title = string.Format(Title, detailsModel.TestName); foreach (var tag in detailsModel.Tags) { //: Add to interface, but how to display? } ExpScript.Collapsed += ExpScript_Collapsed; ExpScript.Expanded += ExpScript_Expanded; }
void setTestData(TestDetailsModel test) { try { _isTimeForEntireTest = test.SetTimeForAllTest; _timeForCompletion = test.TimeForCompleting; _questionCount = test.CountOfQuestions; _testIdString = test.Id.ToString(); } catch (Exception ex) { AppLogs.Log(ex); } }
/// <summary> /// When creating a test we need a name for the test. After getting the name from GetInput window, /// we show the TestDetails window with a blank TestDetails model, which will save the test if they /// so choose. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param> private void btnAddTest_Click(object sender, RoutedEventArgs e) { var inputDialog = new GetInput("Test Name"); inputDialog.ShowDialog(); var input = inputDialog.Input; //:todo - add validation input was received var tdm = new TestDetailsModel(input, "", "", new List<string>()); var t = new TestDetails(tdm, (RepositoryInfo)cbProjects.SelectedItem); t.ShowDialog(); LoadTests(); }
public async Task <int> InactiveAthleteInTestAsync(TestDetailsModel testDetailsModel) { var result = 0; try { var cmd = new MySqlCommand(); cmd.CommandText = @"Delete from testdetails where TestId = " + testDetailsModel.TestId + " and UserId = " + testDetailsModel.UserId + ";"; cmd.Connection = _dbConfig.Connection; _dbConfig.Connection.Open(); result = await cmd.ExecuteNonQueryAsync(); } catch (Exception ex) { } return(result); }
public async Task <int> UpdateAthleteInTestAsync(TestDetailsModel testDetailsModel) { var result = 0; try { var cmd = new MySqlCommand(); cmd.CommandText = @"Update `testdetails` Set Result = " + testDetailsModel.Result + " where UserId =" + testDetailsModel.UserId + " and TestId = " + testDetailsModel.TestId + ";"; cmd.Connection = _dbConfig.Connection; _dbConfig.Connection.Open(); result = await cmd.ExecuteNonQueryAsync(); _dbConfig.Connection.Close(); } catch (Exception ex) { } return(result); }
public IActionResult UpdateAthleteInTest([FromBody] TestDetailsModel testDetailsModel) { var output = _atheletService.UpdateAthleteInTest(testDetailsModel).Result; return(Json(output)); }
/// <summary> /// Initializes a new instance of the <see cref="TestDetailsContext"/> class. /// </summary> /// <param name="detailsModel">The TestDetails model.</param> public TestDetailsContext(TestDetailsModel detailsModel) { DetailsModel = detailsModel; }
public async Task <int> UpdateAthleteInTest(TestDetailsModel testDetailsModel) { return(await _atheletDb.UpdateAthleteInTestAsync(testDetailsModel)); }