예제 #1
0
        public async Task <UserIdentificationResultDto> IdentifyUser(IdentityUrlDto urlDto)
        {
            var url = await urlRepository.GetByIdAsync(id : urlDto.Id);

            var urlValidator        = new UrlValidator();
            var urlValidationResult = urlValidator.Validate(url);

            UserIdentificationResultDto userIdentificationResult;

            if (!urlValidationResult.IsValid)
            {
                userIdentificationResult            = mapper.Map <UserIdentificationResultDto>(urlValidationResult);
                userIdentificationResult.IsUrlValid = false;
                return(userIdentificationResult);
            }

            if (url.NumberOfRuns.HasValue && url.NumberOfRuns > 0)
            {
                --url.NumberOfRuns;
                urlRepository.Update(url);
                await unitOfWork.SaveAsync();
            }

            var intervieweeNameValidator        = new UrlIntervieweeNameValidator(urlDto.IntervieweeName);
            var intervieweeNameValidationResult = intervieweeNameValidator.Validate(url);

            userIdentificationResult            = mapper.Map <UserIdentificationResultDto>(intervieweeNameValidationResult);
            userIdentificationResult.IsUrlValid = true;
            return(userIdentificationResult);
        }
예제 #2
0
        public async Task <ActionResult <UserIdentificationResultDto> > IdentifyUser([FromBody] IdentityUrlDto urlDto)
        {
            if (urlDto == null)
            {
                return(BadRequest());
            }

            return(Ok(await urlValidatorService.IdentifyUser(urlDto)));
        }