Beispiel #1
0
        //Get user from DB
        public userDTO GetUser(logInDTO loggedUser)
        {
            var user = from u in DB.Users
                       where loggedUser.userName == u.userName && loggedUser.password == u.userPasword
                       select new userDTO
            {
                firstName   = u.userFirstName,
                lastName    = u.userLastName,
                IdOfUser    = u.userID,
                nameOfUser  = u.userName,
                dateOfBirth = u.userBirthDate,
                email       = u.userEmail,
                gender      = u.userGender,
                password    = u.userPasword,
                image       = u.userImage,
                role        = u.userRole
            };

            if (user.Any())
            {
                return(user.SingleOrDefault());
            }
            else
            {
                return(new userDTO
                {
                    nameOfUser = null,
                    password = null
                });
            }
        }
Beispiel #2
0
 public HttpResponseMessage GetUser(logInDTO logIn)
 {
     try
     {
         userDTO userFound = logic.GetUser(logIn);
         return(Request.CreateResponse(HttpStatusCode.OK, userFound));
     }
     catch (Exception ex)
     {
         return(Request.CreateErrorResponse(
                    HttpStatusCode.InternalServerError,
                    ErrorsManager.GetInnerMessage(ex)));
     }
 }