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] CreateExam command) { command.ExamId = Guid.NewGuid(); await _examService.CreateAsync(command.ExamId, command.Name, command.Description, command.StartDate, command.EndDate); return(Created($"/exams/{command.ExamId}", null)); }
public async Task <IActionResult> Insert([FromBody] ExamDto dto) { var result = await _examService.CreateAsync(dto); if (result == null) { return(NotFound()); } return(Ok(result)); }
public async Task <string> CreateExamAsync(string facultyname, DateTime dayy, int hall, int duration, int course, string starttime, string examname) { if (!await _examService.IsValidExamNameAsync(facultyname, examname, course)) { return("false examname"); } else if (!await _examService.IsValidDayAndHallAsync(hall, dayy, starttime)) { return("false dayandhall"); } else { await _examService.CreateAsync(facultyname, dayy, hall, duration, course, starttime, examname); } return("true"); }