private async Task <Guid> CreateTestFlowAsync() { string testName = SharedConsoleFlows.AskForString("What is the name of the test?"); byte numberOfVersions = SharedConsoleFlows.AskForByte("How many versions are there?"); byte minimumGrade = SharedConsoleFlows.AskForByte("What is the minimum grade?"); byte standardizationFactor = SharedConsoleFlows.AskForByte("What is the standardization factor?"); var createTestRequest = new CreateTestRequest() { Name = testName, MinimumGrade = minimumGrade, StandardizationFactor = standardizationFactor, NumberOfVersions = numberOfVersions }; CreateTestResult createTestResponse = await _testController.CreateTestAsync(createTestRequest); Guid testId = createTestResponse.TestId; if (createTestResponse.ValidationMessages.Any()) { SharedConsoleFlows.PrintValidationMessages(createTestResponse.ValidationMessages); testId = await CreateTestFlowAsync(); } return(testId); }
private async Task AddStudentFlowAsync(Guid classId) { string firstName = SharedConsoleFlows.AskForString("What is the first name of the student?"); string infix = SharedConsoleFlows.AskForOptionalString("What is the infix of the student?"); string lastName = SharedConsoleFlows.AskForString("What is the last name of the student?"); var model = new AddStudentRequest { ClassId = classId, FirstName = firstName, Infix = infix, LastName = lastName }; AddStudentResult addStudentResponse = await _classController.AddStudentAsync(model); if (addStudentResponse.ValidationMessages.Any()) { SharedConsoleFlows.PrintValidationMessages(addStudentResponse.ValidationMessages); await AddStudentFlowAsync(classId); } }
/// <inheritdoc/> public async Task StartAsync() { Console.Clear(); Cifra.Application.Models.Class.Class chosenClass = await AskForClassAsync(); Cifra.Application.Models.Test.Test chosenTest = await AskForTestAsync(); Console.Clear(); string fileName = SharedConsoleFlows.AskForString("What should be the name of the spreadsheet?"); SaveResult saveResult = await BuildSpreadsheetAsync(chosenClass, chosenTest, fileName); if (saveResult.IsSuccess) { Console.WriteLine("File successfully saved."); SharedConsoleFlows.AskForAnyKey("Press any key to go back"); } else { Console.WriteLine("File not saved due to an error."); SharedConsoleFlows.AskForAnyKey("Press any key to go back"); } }