Esempio n. 1
0
        public static void RemoveUser(string username)
        {
            using (var db = new JournalsContext())
            {
                var userToDelete = db.Users.FirstOrDefault(u => u.Username == username);

                if (userToDelete != null)
                {
                    RemoveUser(userToDelete);
                }
            }
        }
Esempio n. 2
0
        public static void RemoveUser(User user)
        {
            if (user == null)
            {
                return;
            }

            using (var db = new JournalsContext())
            {
                db.Users.Remove(user);
                db.SaveChanges();
            }
        }
Esempio n. 3
0
        public static User GetUserByUsername(string username)
        {
            User foundUser = null;

            using (var db = new JournalsContext())
            {
                if (db.Users.Any())
                {
                    foundUser = db.Users.FirstOrDefault(u => u.Username == username);
                }
            }

            return(foundUser);
        }