public async Task <TestingPersonnelDto> CreateTestingPersonnelAsync(TestingPersonnelSpecDto specDto) { if (specDto == null) { throw new ArgumentNullException(nameof(specDto)); } var existingTestingPersonnelId = await _testingPersonnelsRepository.GetTestingPersonnelIdByEmailAsync(specDto.Email) .ConfigureAwait(false); if (existingTestingPersonnelId != Guid.Empty) { ValidationDictionary .AddModelError("Testing personnel with this email already exists", $"{specDto.Email}"); return(null); } var testingPersonnel = await AddAsync(specDto) .ConfigureAwait(false); return(testingPersonnel); }
public async Task <ActionResult <PagedResults <TestingPersonnelDto> > > CreateTestingPersonnelAsync([FromBody] TestingPersonnelSpecDto specDto) { if (specDto == null) { return(BadRequest()); } var testingPersonnel = await _testingPersonnelsService .CreateTestingPersonnelAsync(specDto) .ConfigureAwait(false); if (!_testingPersonnelsService.ValidationDictionary.IsValid()) { return(BadRequest(new { errors = _testingPersonnelsService.ValidationDictionary.GetErrorMessages() })); } return(Ok(testingPersonnel.Id)); }