Пример #1
0
        public async Task <IActionResult> GetUserContacts(long id)
        {
            GetUserContactsRequestDto message = new GetUserContactsRequestDto()
            {
                UserID = id.AsInt()
            };

            if (await message.IsValid())
            {
                var response = await _policy.ExecuteAsync(async() => await _getUserContactsClient.Request(message));

                if (response != null)
                {
                    return(Ok(response));
                }
            }
            return(BadRequest());
        }
Пример #2
0
        public async Task DataValidatorTest()
        {
            DataValidator <GetUserContactsRequestDto> validator = new DataValidator <GetUserContactsRequestDto>();

            GetUserContactsRequestDto message = new GetUserContactsRequestDto()
            {
                UserID = -2
            };

            bool result = await validator.IsValid(message);

            result.Should().BeFalse();

            message.UserID = 2;

            result = await validator.IsValid(message);

            result.Should().BeTrue();
        }