예제 #1
0
        public async Task Register_Fail(string phone, string password)
        {
            Setup();

            var listClients = new List <Dal.Models.Client>()
            {
                new()
                {
                    Login = "******"
                }
            };

            _applicationContextMock.Setup(x => x.Clients).ReturnsDbSet(listClients);

            _testedService = new ClientsService(Logger, _applicationContextMock.Object);

            var model = new ClientDto()
            {
                Login    = phone,
                Password = password,
                Name     = "Maga"
            };

            var result = await _testedService.Register(model, CancellationToken.None);

            Assert.Empty(result);
        }
        public async Task <IActionResult> Register([FromBody] ClientDto model, CancellationToken cancellationToken)
        {
            if (model == null)
            {
                return(BadRequest());
            }

            if (ModelState.IsValid)
            {
                var result = await _clientsService.Register(model, cancellationToken);

                if (!string.IsNullOrEmpty(result))
                {
                    return(Ok(result));
                }

                return(Conflict());
            }

            return(BadRequest());
        }