Exemple #1
0
        public async Task <string> LogIn(string username, string password)
        {
            DataUser u = await usersDAL.GetDataUser(username);

            if (u != null)
            {
                if (u.password.Equals(EncryptString(key, password)))
                {
                    if (u.IsLoggedin)
                    {
                        return("user is already logged in");
                    }
                    else
                    {
                        u.IsLoggedin = true;
                        await ProxyMarketContext.Instance.saveChanges();

                        return("success");
                    }
                }

                else
                {
                    return("the password doesn't match username: "******"username: "******" doesn't exist in the system");
        }
Exemple #2
0
        public async Task <bool> isLoggedIn(string username)
        {
            DataUser u = await usersDAL.GetDataUser(username);

            if (u != null)
            {
                return(false);
            }
            return(u.IsLoggedin);
        }
Exemple #3
0
        private async Task <Result <String> > getUserPhone(string username)
        {
            DataUser u = await usersDAL.GetDataUser(username);

            if (u != null)
            {
                return(new Result <string>(u.phone, false, ""));
            }
            return(new Result <string>(null, true, "username doesn't exist"));
        }
Exemple #4
0
        public async Task <bool> Logout(string username)
        {
            if (username == null)
            {
                return(false);
            }
            DataUser u = await usersDAL.GetDataUser(username);

            if (u != null)
            {
                if (u.IsLoggedin == false)
                {
                    return(false);
                }
                u.IsLoggedin = false;
                await ProxyMarketContext.Instance.saveChanges();

                return(true);
            }
            return(false);
        }
Exemple #5
0
        //for unit test
        public async Task <bool> DeleteUser(string username)
        {
            DataUser u = null;

            return(await usersDAL.RemoveDataUser(username));
        }