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 } }
public int GetUserId(int Id) { using (UserDataContext dataContext = new UserDataContext()) { User user = dataContext.Users.FirstOrDefault(u => u.Id == Id); return(user.Id); } }
public Link AddLink(Link l) { using (UserDataContext dataContext = new UserDataContext()) { dataContext.Links.InsertOnSubmit(l); dataContext.SubmitChanges(); return(l); } }
public Link AddLink(Link l) { using (UserDataContext dataContext = new UserDataContext()) { dataContext.Links.InsertOnSubmit(l); dataContext.SubmitChanges(); return l; } }
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); } }
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; } }
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); } }
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); } }
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; } }
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); } }
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; } }
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 } }
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 } }
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; } }
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); } }
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; } }
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; } }
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 } }
public int GetUserId(int Id) { using (UserDataContext dataContext = new UserDataContext()) { User user = dataContext.Users.FirstOrDefault(u => u.Id == Id); return user.Id; } }