public async Task <ActionResult> CancelConfirmationAsync([FromBody] TestingPersonnelCancelConfrimationSpecDto specDto) { if (specDto == null) { return(BadRequest()); } var loggedUserId = HttpContext.User.Claims.First(x => x.Type == JwtRegisteredClaimNames.Jti).Value; specDto.CanceledByUserId = Guid.Parse(loggedUserId); await _testingPersonnelInvitationsService .CancelConfirmationAsync(specDto) .ConfigureAwait(false); if (!_testingPersonnelInvitationsService.ValidationDictionary.IsValid()) { return(BadRequest(new { errors = _testingPersonnelInvitationsService.ValidationDictionary.GetErrorMessages() })); } return(Ok()); }
public async Task CancelConfirmationAsync(TestingPersonnelCancelConfrimationSpecDto specDto) { if (specDto == null) { throw new ArgumentNullException(nameof(specDto)); } var invitationId = await _testingPersonnelInvitationsRepository.GetInvitationIdByDateAsync(specDto.Date.Date) .ConfigureAwait(false); if (invitationId == Guid.Empty) { ValidationDictionary .AddModelError("Invitation for date was not found", $"{specDto.Date.ToString(dateFormat, CultureInfo.InvariantCulture)}"); return; } var testingPersonnelId = await _testingPersonnelsRepository.GetTestingPersonnelIdByEmailAsync(specDto.Email) .ConfigureAwait(false); if (testingPersonnelId == Guid.Empty) { ValidationDictionary .AddModelError("Testing personnel with email was not found", $"{specDto.Email}"); return; } await _testingPersonnelConfirmationsRepository .CancelInvitationConfirmationAsync(invitationId, testingPersonnelId, specDto.CanceledByUserId) .ConfigureAwait(false); }