Ejemplo n.º 1
0
        public ResultLoginRowData GetInfoUser(AccountRowData data)
        {
            ResultLoginRowData result = new ResultLoginRowData();

            try
            {
                string sql = @"
                    SELECT 
	                    USER_ID,
	                    FULL_NAME,
	                    EMAIL,
	                    PHONE,
	                    PASSWORD,
	                    ADDRESS,
                        USER_TYPE
                    FROM S_USER
                    WHERE EMAIL = '" + data.Email + @"'
                    OR PHONE = '" + data.Email + @"'
                    ";
                result = dbcontext.Database.SqlQuery <ResultLoginRowData>(sql).FirstOrDefault();
                if (result != null)
                {
                    result.IS_SUCCESS = true;
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex);
            }
            return(result);
        }
Ejemplo n.º 2
0
        public string GetSessionUserID(AccountRowData model)
        {
            string userID = string.Empty;

            try
            {
                userID = dbcontext.S_USER.FirstOrDefault(x => x.EMAIL == model.Email || x.PHONE == model.Email).USER_ID;
            }
            catch (Exception ex)
            {
                logger.Error("GetSessionEmail - " + ex);
            }
            return(userID);
        }
Ejemplo n.º 3
0
        public string GetSessionEmail(AccountRowData model)
        {
            string email = string.Empty;

            try
            {
                email = dbcontext.S_USER.FirstOrDefault(x => x.EMAIL == model.Email || x.PHONE == model.Email).EMAIL;
            }
            catch (Exception ex)
            {
                logger.Error("GetSessionEmail - " + ex);
            }
            return(email);
        }
Ejemplo n.º 4
0
        public string GetFullName(AccountRowData model)
        {
            string fullname = string.Empty;

            try
            {
                fullname = dbcontext.S_USER.FirstOrDefault(x => x.EMAIL == model.Email || x.PHONE == model.Email).FULL_NAME;
            }
            catch (Exception ex)
            {
                logger.Error("GetFullName - " + ex);
            }
            return(fullname);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// check group is admin or user
        /// </summary>
        /// <param name="username"></param>
        /// <returns>true : group admin, false : group user</returns>
        public bool checkGoupAdmin(AccountRowData model)
        {
            bool result = false;

            try
            {
                string sql = @"
                    SELECT COUNT(*) FROM S_USER S
                    INNER JOIN D_GROUP_PERMISSION D ON S.USER_ID = D.USER_ID
                    WHERE (S.EMAIL = '" + model.Email + @"' OR S.PHONE = '" + model.Email + @"') 
                    AND D.PERMISSION_ID = '" + ConstantClass.GROUP_ADMIN + @"'
                    ";
                int    res = dbcontext.Database.SqlQuery <int>(sql).FirstOrDefault();
                result = (res > 0 ? true : false);
            }
            catch (Exception ex)
            {
                logger.Error("checkGoupAdmin - " + ex);
                result = false;
            }
            return(result);
        }
Ejemplo n.º 6
0
        public ResultLoginRowData CheckLoginMobile(AccountRowData data)
        {
            ResultLoginRowData result = new ResultLoginRowData();

            try
            {
                bool isResult = Login(data);
                if (isResult)
                {
                    result = GetInfoUser(data);
                }
                else
                {
                    result.IS_SUCCESS = false;
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex);
            }
            return(result);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Login
        /// </summary>
        /// <param name="username"></param>
        /// <param name="password"></param>
        /// <returns>true : login success, false : login false</returns>
        public bool Login(AccountRowData data)
        {
            bool result = false;

            try
            {
                var    pass = commomFunction.MD5Hash(data.Password);
                string sql  = @"
                    SELECT COUNT(*) FROM S_USER WHERE (EMAIL = '" + data.Email + "' OR PHONE = '" + data.Email + "') AND PASSWORD = '******'
                    ";

                int record = dbcontext.Database.SqlQuery <int>(sql).FirstOrDefault();
                result = record != 0 ? true : false;
                return(result);
            }
            catch (Exception ex)
            {
                // write log
                logger.Error("Login - " + ex);
                result = false;
            }
            return(result);
        }