Ejemplo n.º 1
0
        public IHttpActionResult PostLoginModel(LoginModel loginModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            ObjectParameter Output = new ObjectParameter("responseMessage", typeof(string));
            ObjectParameter idCard = new ObjectParameter("idCard", typeof(int));

            db.PR_HikerLogin(loginModel.Username, loginModel.Password, Output, idCard);
            var r = new LoginResult()
            {
                Success = false, Msg = Output.Value.ToString()
            };

            if (!(idCard.Value is DBNull))
            {
                r.IdCard = Convert.ToInt32(idCard.Value);
            }

            if (Output.Value.ToString().Equals("User successfully logged in"))
            {
                r.Success = true;
            }

            return(Ok(r));
        }