public async Task <IActionResult> AddIdentityNumber(IdsDto idsDto) { try { if (string.IsNullOrWhiteSpace(idsDto.idNumbers)) { return(BadRequest("No identity numbers in request")); } //split identity numbers from request var idNumbers = idsDto.idNumbers.Trim() .Split(new string[] { "\r\n", "\r", "\n" }, StringSplitOptions.None); //Get the valid and invalid id information if they exist. IdInfo idInfo = _identityNumberService.ExtractIdInformation(idNumbers, _identityNumberValidator); // Save to data store: In case as a csv file if (idInfo.validIdInfos.Any()) { await _dataRepository.Save(idInfo.validIdInfos); } if (idInfo.InvalidIdInfos.Any()) { await _dataRepository.Save(idInfo.InvalidIdInfos); } return(NoContent()); } catch (Exception e) { _logger.LogError(e.Message, e); return(StatusCode(500, e.Message)); } }
public async Task AddIdentityNumber_GivenAnEmptyStringAsIds_ReturnsABadRequest() { var iddto = new IdsDto { idNumbers = " " }; var result = await _identityNumberController.AddIdentityNumber(iddto); _dataRepository.Verify(x => x.Save(It.IsAny <List <ValidIDInfo> >()), Times.Never); Assert.That(result, Is.InstanceOf <BadRequestObjectResult>()); }
public async Task AddIdentityNumber_GivenValidAndInvalidId_EnsureThatOutputsIsSavedToCsv() { var iddto = new IdsDto { idNumbers = "8605065447083\r\n8605065397083\r\n" }; var result = await _identityNumberController.AddIdentityNumber(iddto); _dataRepository.Verify(x => x.Save(It.IsAny <List <ValidIDInfo> >()), Times.AtLeastOnce); Assert.That(result, Is.InstanceOf <NoContentResult>()); }
public SubmitCallForSpeechCommandResponse(IdsDto callForSpeechid) { CallForSpeechCommandIds = callForSpeechid; }
public ESCreateCategoryCommandResponse(IdsDto Ids) : base() { CategoryIds = Ids; }
public EsCreateJudgeCommandResponse(IdsDto judgeIds) { JudgeIds = judgeIds; }
public EsSubmitCallForSpeechCommandResponse(IdsDto Ids) : base() { CallForSpeechIds = Ids; }
public CreatedCategoryCommandResponse(IdsDto categoryIds) : base() { CategoryIds = categoryIds; }