Esempio n. 1
0
        public async Task SeedAsync()
        {
            Logger.Trace("Initializing data...");
            var tasks = new List <Task>();

            for (var i = 1; i <= 10; i++)
            {
                Guid userId   = Guid.NewGuid();
                var  username = $"user{i}";

                await _userService.RegisterAsync(userId, $"admin{i}@test.com", username, "secret", "admin");

                Logger.Trace($"Adding user: '******'.");

                Guid examId          = Guid.NewGuid();
                var  examName        = $"exam{i}";
                var  examDescription = $"{examName} description.";
                var  startDate       = DateTime.UtcNow.AddHours(3);
                var  endDate         = startDate.AddHours(2);

                await _examService.CreateAsync(examId, examName, examDescription, startDate, endDate);

                Logger.Trace($"Adding exam: '{examName}'.");

                await _exerciseService.AddAsync(examId, "NameOfExercise", "Question",
                                                "answerA", "answerB", "answerC", "answerD");

                Logger.Trace($"Adding exercise for '{examName}'.");
            }

            await Task.WhenAll(tasks);

            Logger.Trace("Data was initialized.");
        }
        public async Task <IActionResult> Post([FromBody] CreateExamExercise command)
        {
            await _examExerciseService.AddAsync(command.ExamId, command.Name, command.Question,
                                                command.AnswerA, command.AnswerB, command.AnswerC, command.AnswerD);

            return(NoContent());
        }