public async Task TrialExamShouldBeCreated() { using var testServer = await CreateWithUserAsync(); var client = testServer.CreateClient(); var command = new CreateExamCommand( Guid.NewGuid(), "3.Trial", DateTime.Now, 7, 0, "Frm3rdGradeTrial", 1, 0, 1, null, Random.RandomString(100)); var response = await client.PostAsync(ApiPath, command.ToJsonContent()); response.EnsureSuccessStatusCode(); var exams = await GetExamListAsync(client); exams.Should().Contain(e => e.Name == command.Name && e.IncorrectEliminationRate == command.IncorrectEliminationRate && e.Notes == command.Notes && e.ExamBookletTypeId == command.ExamBookletTypeId && e.ExamTypeId == command.ExamTypeId); }
public async Task <IActionResult> CreateAsync(CreateExamCommand command) { if (!User.IsInRole(Roles.Admin)) { command.Shared = false; } await _commandProcessor.SendAsync(command); return(Ok()); }
protected async Task <CreateExamCommand> CreateExamAsync( HttpClient client) { var examType = await GetRandomExamTypeAsync(client); var command = new CreateExamCommand( Guid.NewGuid(), Random.RandomString(100), DateTime.Today, examType.Id, 3, examType.OpticalFormTypes.Random().Code, 1, 1 + Random.Next(10), 2, null, Random.RandomString(200)); var response = await client.PostAsync(ApiPath, command.ToJsonContent()); response.EnsureSuccessStatusCode(); return(command); }
public async Task <IActionResult> CreateAsync([FromBody, Required] CreateExamCommand command) { await _commandProcessor.SendAsync(command); return(Ok()); }
public Task <IActionResult> Create(CreateExamRequest request) { return(CreatedOrUnprocessableEntityAsync <CreateExamCommand, ExamId>( CreateExamCommand.Create(request, _subjectExistenceValidator, _locationExistenceValidator), id => $"/api/exams/{id}")); }