Ejemplo 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
     }
 }
Ejemplo 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);
            }
        }
Ejemplo n.º 3
0
        public Link AddLink(Link l)
        {
            using (UserDataContext dataContext = new UserDataContext())
            {
                dataContext.Links.InsertOnSubmit(l);
                dataContext.SubmitChanges();

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

                return l;
            }
        }
Ejemplo 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);
            }
        }
Ejemplo 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;
            }
        }
Ejemplo 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);
            }
        }
Ejemplo 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);
            }
        }
Ejemplo 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;
            }
        }
Ejemplo 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);
            }
        }
Ejemplo 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;
            }
        }
Ejemplo 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
            }
        }
Ejemplo 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
            }
        }
Ejemplo 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;
            }
        }
Ejemplo 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);
            }
        }
Ejemplo 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;
            }
        }
Ejemplo 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;
            }
        }
Ejemplo 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

            }
        }
Ejemplo 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;

            }
        }