Esempio n. 1
0
        public async Task <(TestRunResponse, bool isNew, ServiceError)> ReplaceTestRun(
            int sessionId, int testRunId, TestRunRequest testRunRequest)
        {
            var testRun = await _dbService.Query <TestRun>(testRunId).Include(r => r.ExtraData).FirstOrDefaultAsync();

            bool isNew;

            if (testRun == null)
            {
                isNew   = true;
                testRun = testRunRequest.ToDataModel(sessionId);
                _dbService.Add(testRun);
            }
            else
            {
                isNew = false;
                if (testRun.TestRunSessionId != sessionId)
                {
                    return(null, false, ServiceError.NotFound($"TestRun with Id of {testRunId} does not belong to session {sessionId}."));
                }
                testRunRequest.Update(testRun);
            }
            await _dbService.SaveChangesAsync();

            return(testRun.ToResponse(), isNew, null);
        }
Esempio n. 2
0
        public async Task <TestRunResponse> InsertTestRunAsync(int sessionId, TestRunRequest testRunRequest)
        {
            var testRun = testRunRequest.ToDataModel(sessionId);
            await _dbService.InsertAsync(testRun);

            return(testRun.ToResponse());
        }