Exemplo n.º 1
0
        public static LoginResult LogIn(string userName, string userPassword)
        {
            using (var db = new MySqlProvider())
            {
                var queryResult = (from p in db.User
                                   where p.UserName == userName &&
                                   p.UserIsValid
                                   select p).FirstOrDefault();

                LoginResult result = new LoginResult();

                if (queryResult == null)
                {
                    result.Response = LoginResponse.NotFound;
                }
                else
                {
                    result.Response = LoginResponse.Success;
                    result.User     = new Business.Classes.User.User()
                    {
                        UserID   = queryResult.UserID,
                        UserName = queryResult.UserName
                    };
                }
                return(result);
            }
        }
Exemplo n.º 2
0
        public static List <Business.Classes.User.User> All()
        {
            using (var db = new MySqlProvider())
            {
                var query = from p in db.User
                            select p;

                return(query.ToList().Select(userDB => new Business.Classes.User.User()
                {
                    UserID = userDB.UserID, UserName = userDB.UserName
                }).ToList());
            }
        }