Пример #1
0
        public static User IsUserPassCorrect(string username, string password)
        {
            //foreach (User user in TestUsers)
            //{
            //    if (user.Username.Equals(username) && user.Password.Equals(password))
            //    {
            //        return user;
            //    }
            //}
            //return null;
            UserLoginContext context = new UserLoginContext();

            User result =
                (from st in context.Users
                 where st.Username == username
                 select st).FirstOrDefault();

            if (result == null)
            {
                return(null);
            }
            if (!PasswordHash.ComparePass(password, result.Password))
            {
                return(null);
            }
            return(result);
        }
Пример #2
0
        static void CopyLogs()
        {
            UserLoginContext context = new UserLoginContext();
            Logs             log     = new Logs();

            log.Activity = currentSessionActivities.Last();
            context.Logs.Add(log);
            context.SaveChanges();
        }
Пример #3
0
        public static void AssignUserRole(string username, UserRoles newUserRole)
        {
            //foreach (User user in TestUsers)
            //{
            //    if (user.Username == username)
            //    {
            //        user.UserRole = newUserRole;
            //        Logger.LogActivity("Change role of " + username);
            //    }
            //}
            UserLoginContext context = new UserLoginContext();
            User             usr     =
                (from u in UserData.TestUsers
                 where u.Username == username
                 select u).First();

            usr.UserRole = newUserRole;
            context.SaveChanges();
        }
Пример #4
0
        public static void SetUserActiveTo(string username, DateTime newDateActive)
        {
            //foreach (User user in TestUsers)
            //{
            //    if (user.Username == username)
            //    {
            //        user.DateActive = newDateActive;
            //        Logger.LogActivity("Change activity of " + username);
            //    }
            //}
            UserLoginContext context = new UserLoginContext();
            User             usr     =
                (from u in UserData.TestUsers
                 where u.Username == username
                 select u).First();

            usr.DateActive = newDateActive;
            Logger.LogActivity("Change activity of " + username);
            context.SaveChanges();
        }