Esempio n. 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
     }
 }
Esempio n. 2
0
        public int GetUserId(int Id)
        {
            using (UserDataContext dataContext = new UserDataContext())
            {
                User user = dataContext.Users.FirstOrDefault(u => u.Id == Id);

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

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

                return l;
            }
        }
Esempio n. 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);
            }
        }
Esempio n. 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;
            }
        }
Esempio n. 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);
            }
        }
Esempio n. 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);
            }
        }
Esempio n. 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;
            }
        }
Esempio n. 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);
            }
        }
Esempio n. 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;
            }
        }
Esempio n. 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
            }
        }
Esempio n. 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
            }
        }
Esempio n. 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;
            }
        }
Esempio n. 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);
            }
        }
Esempio n. 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;
            }
        }
Esempio n. 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;
            }
        }
Esempio n. 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

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

                return user.Id;

            }
        }