示例#1
0
        public int Login(string userName, string password)
        {
            var result = new SqlParameter
            {
                ParameterName = "result",
                DbType        = System.Data.DbType.Int32,
                Direction     = System.Data.ParameterDirection.Output
            };

            password = HashAndSalt.GenerateHash(password);
            _db.Database.ExecuteSqlCommand($"exec Login @p0,@p1,@result out", userName, password, result);
            return((int)result.Value);
        }
示例#2
0
        public int Register(User user)
        {
            var result = new SqlParameter
            {
                ParameterName = "result",
                DbType        = System.Data.DbType.Int32,
                Direction     = System.Data.ParameterDirection.Output
            };
            string password = HashAndSalt.GenerateHash(user.Password);

            _db.Database.ExecuteSqlCommand($"exec Register @p0,@p1,@p2,@result out", user.Username, password, user.Phone, result);
            return((int)result.Value);
        }