예제 #1
0
 public bool UserAutherntification(string username, string password)
 {
     using (UserDataContext dataContext = new UserDataContext())
     {
         User u = dataContext.Users.FirstOrDefault(i => i.UserName == username);
         bool correctPassword = PasswordHelper.PasswordMatch(password, u.HashPassword, u.Salt);
         return(correctPassword ? true : false); //ternary operator
     }
 }
예제 #2
0
        public int GetUserId(int Id)
        {
            using (UserDataContext dataContext = new UserDataContext())
            {
                User user = dataContext.Users.FirstOrDefault(u => u.Id == Id);

                return(user.Id);
            }
        }
예제 #3
0
        public Link AddLink(Link l)
        {
            using (UserDataContext dataContext = new UserDataContext())
            {
                dataContext.Links.InsertOnSubmit(l);
                dataContext.SubmitChanges();

                return(l);
            }
        }
예제 #4
0
        public Link AddLink(Link l)
        {
            using (UserDataContext dataContext = new UserDataContext())
            {
                dataContext.Links.InsertOnSubmit(l);
                dataContext.SubmitChanges();

                return l;
            }
        }
예제 #5
0
        public int GetUserbyUsername(string username)
        {
            using (UserDataContext dataContext = new UserDataContext())
            {
                DataLoadOptions loadOptions = new DataLoadOptions();
                loadOptions.LoadWith <User>(u => u.Links);
                dataContext.LoadOptions = loadOptions;

                User user = dataContext.Users.FirstOrDefault(u => u.UserName == username);

                return(user.Id);
            }
        }
예제 #6
0
        public IEnumerable<User> GetAllUser()
        {
            using (UserDataContext dataContext = new UserDataContext())
            {

                DataLoadOptions loadOptions = new DataLoadOptions();
                loadOptions.LoadWith<Link>(l => l.Uploads);
                loadOptions.LoadWith<User>(u=>u.Links);
                dataContext.LoadOptions = loadOptions;

                IEnumerable<User> Users = dataContext.Users.ToList();
                return Users;
            }
        }
예제 #7
0
        public IEnumerable <Link> GetAllLinks()
        {
            using (UserDataContext dataContext = new UserDataContext())
            {
                DataLoadOptions loadOptions = new DataLoadOptions();
                loadOptions.LoadWith <Link>(l => l.Uploads);
                loadOptions.LoadWith <Link>(l => l.User);
                dataContext.LoadOptions = loadOptions;

                IEnumerable <Link> Links = dataContext.Links.ToList();

                return(Links);
            }
        }
예제 #8
0
        public IEnumerable <User> GetAllUser()
        {
            using (UserDataContext dataContext = new UserDataContext())
            {
                DataLoadOptions loadOptions = new DataLoadOptions();
                loadOptions.LoadWith <Link>(l => l.Uploads);
                loadOptions.LoadWith <User>(u => u.Links);
                dataContext.LoadOptions = loadOptions;


                IEnumerable <User> Users = dataContext.Users.ToList();
                return(Users);
            }
        }
예제 #9
0
        public IEnumerable<Link> GetAllLinks()
        {
            using (UserDataContext dataContext = new UserDataContext())
            {

                DataLoadOptions loadOptions = new DataLoadOptions();
                loadOptions.LoadWith<Link>(l => l.Uploads);
                loadOptions.LoadWith<Link>(l=>l.User);
                dataContext.LoadOptions = loadOptions;

                IEnumerable<Link> Links = dataContext.Links.ToList();

                return Links;
            }
        }
예제 #10
0
        public IEnumerable <Link> GetLinkbyUserId(int UserId)
        {
            using (UserDataContext dataContext = new UserDataContext())
            {
                DataLoadOptions loadOptions = new DataLoadOptions();
                loadOptions.LoadWith <Link>(l => l.Uploads);
                loadOptions.LoadWith <Link>(l => l.User);
                dataContext.LoadOptions = loadOptions;

                User u = dataContext.Users.FirstOrDefault(user => user.Id == UserId);

                IEnumerable <Link> linksByUser = dataContext.Links.Where(l => l.UserId == u.Id).ToList();

                return(linksByUser);
            }
        }
예제 #11
0
        public IEnumerable<Link> GetLinkbyUsers(string userName)
        {
            using (UserDataContext dataContext = new UserDataContext())
            {

                DataLoadOptions loadOptions = new DataLoadOptions();
                loadOptions.LoadWith<Link>(l => l.Uploads);
                loadOptions.LoadWith<Link>(l => l.User);
                dataContext.LoadOptions = loadOptions;

                User u = dataContext.Users.FirstOrDefault(user => user.UserName == userName);

                IEnumerable<Link> linksByUser = dataContext.Links.Where(l => l.Id == u.Id).ToList();

                return linksByUser;
            }
        }
예제 #12
0
        public User GetUser(string username, string password)
        {
            using (UserDataContext dataContext = new UserDataContext())
            {
                DataLoadOptions loadOptions = new DataLoadOptions();
                loadOptions.LoadWith<Link>(l => l.Uploads);
                loadOptions.LoadWith<User>(u => u.Links);
                dataContext.LoadOptions = loadOptions;

                User user = dataContext.Users.FirstOrDefault(u => u.UserName == username);
                if (user == null)
                {
                    return null;
                }
                bool correctPassword = PasswordHelper.PasswordMatch(password, user.HashPassword, user.Salt);
                return correctPassword ? user : null; //ternary operator
            }
        }
예제 #13
0
        public User GetUser(string username, string password)
        {
            using (UserDataContext dataContext = new UserDataContext())
            {
                DataLoadOptions loadOptions = new DataLoadOptions();
                loadOptions.LoadWith <Link>(l => l.Uploads);
                loadOptions.LoadWith <User>(u => u.Links);
                dataContext.LoadOptions = loadOptions;

                User user = dataContext.Users.FirstOrDefault(u => u.UserName == username);
                if (user == null)
                {
                    return(null);
                }
                bool correctPassword = PasswordHelper.PasswordMatch(password, user.HashPassword, user.Salt);
                return(correctPassword ? user : null); //ternary operator
            }
        }
예제 #14
0
        public User AddUser(string userName, string password)
        {
            //we should really check if username exists.....
            using (UserDataContext dataContext = new UserDataContext())
            {

                User user = new User();
                user.Salt = PasswordHelper.GenerateSalt();
                user.UserName = userName;
                user.HashPassword = PasswordHelper.HashPassword(password, user.Salt);

                dataContext.Users.InsertOnSubmit(user);

                dataContext.SubmitChanges();

                //user.Id = (int)(decimal)cmd.ExecuteScalar();

                return user;
            }
        }
예제 #15
0
        public User AddUser(string userName, string password)
        {
            //we should really check if username exists.....
            using (UserDataContext dataContext = new UserDataContext())
            {
                User user = new User();
                user.Salt         = PasswordHelper.GenerateSalt();
                user.UserName     = userName;
                user.HashPassword = PasswordHelper.HashPassword(password, user.Salt);


                dataContext.Users.InsertOnSubmit(user);


                dataContext.SubmitChanges();

                //user.Id = (int)(decimal)cmd.ExecuteScalar();

                return(user);
            }
        }
예제 #16
0
        public User GetUserbyUsernameReturnUser(string username)
        {
            using (UserDataContext dataContext = new UserDataContext())
            {
                DataLoadOptions loadOptions = new DataLoadOptions();
                loadOptions.LoadWith<Link>(l => l.Uploads);
                loadOptions.LoadWith<User>(u => u.Links);
                dataContext.LoadOptions = loadOptions;

                User user = dataContext.Users.FirstOrDefault(u => u.UserName == username);

                return user;
            }
        }
예제 #17
0
        public int GetUserbyUsername(string username)
        {
            using (UserDataContext dataContext = new UserDataContext())
            {
                DataLoadOptions loadOptions = new DataLoadOptions();
                loadOptions.LoadWith<User>(u => u.Links);
                dataContext.LoadOptions = loadOptions;

                User user = dataContext.Users.FirstOrDefault(u => u.UserName == username);

                return user.Id;
            }
        }
예제 #18
0
        public bool UserAutherntification(string username, string password)
        {
            using (UserDataContext dataContext = new UserDataContext())
            {
                User u = dataContext.Users.FirstOrDefault(i => i.UserName == username);
                bool correctPassword = PasswordHelper.PasswordMatch(password, u.HashPassword, u.Salt);
                return correctPassword ? true : false; //ternary operator

            }
        }
예제 #19
0
        public int GetUserId(int Id)
        {
            using (UserDataContext dataContext = new UserDataContext())
            {
                User user = dataContext.Users.FirstOrDefault(u => u.Id == Id);

                return user.Id;

            }
        }