public async Task <IActionResult> CreateTestCaseHistoryEntryAsync([FromBody] TestCaseHistoryEntryDto testCaseHistoryEntryDto) { if (testCaseHistoryEntryDto == null) { return(BadRequest()); } if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var testCaseHistoryEntry = Mapper.Map <TestCaseHistoryEntry>(testCaseHistoryEntryDto); var result = await _meissaRepository.InsertWithSaveAsync(testCaseHistoryEntry); var resultDto = Mapper.Map <TestCaseHistoryEntryDto>(result); return(Ok(resultDto)); }
public async Task LoadTestCaseHistoryCollectionAsync() { var testCaseHistoryCollection = new List <TestCaseHistoryDto>(); var testCasesHistoryFilePath = GetTestCasesHistoryFileNamePath(); var testCaseHistoryFileContent = string.Empty; if (_fileProvider.Exists(testCasesHistoryFilePath)) { testCaseHistoryFileContent = await _fileProvider.ReadAllTextAsync(testCasesHistoryFilePath).ConfigureAwait(false); } if (!string.IsNullOrEmpty(testCaseHistoryFileContent)) { testCaseHistoryCollection = _jsonSerializer.Deserialize <List <TestCaseHistoryDto> >(testCaseHistoryFileContent); } if (testCaseHistoryCollection.Any()) { foreach (var testCaseHistory in testCaseHistoryCollection) { var createdTestCaseHistory = await _testCaseHistoryRepository.CreateAsync(testCaseHistory).ConfigureAwait(false); if (testCaseHistory.Durations.Any()) { foreach (var currentDuration in testCaseHistory.Durations) { var testCaseHistoryEntry = new TestCaseHistoryEntryDto { TestCaseHistoryId = createdTestCaseHistory.TestCaseHistoryId, AvgDuration = currentDuration, }; await _testCaseHistoryEntryRepository.CreateAsync(testCaseHistoryEntry).ConfigureAwait(false); } } } } }