Ejemplo n.º 1
0
        public async Task Login_Fail(string phone, string password)
        {
            Setup();

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

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

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

            var model = new LoginContract()
            {
                Login    = phone,
                Password = password
            };

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

            Assert.Empty(result);
        }
    }
Ejemplo n.º 2
0
        public IHttpActionResult Login(ClientModel client)
        {
            DataTable dt = _clientsService.Login(client);

            if (dt.TableName == "Error")
            {
                return(ResponseMessage(Request.CreateErrorResponse((HttpStatusCode)500, new HttpError("Something went wrong"))));
            }

            return(Ok(dt));
        }
        public async Task <IActionResult> Login([FromBody] LoginContract model, CancellationToken cancellationToken)
        {
            if (model == null)
            {
                return(BadRequest());
            }

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

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

                return(BadRequest());
            }

            return(BadRequest());
        }