Ejemplo 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);
                }
            }
        }
Ejemplo n.º 2
0
        public static void RemoveUser(User user)
        {
            if (user == null)
            {
                return;
            }

            using (var db = new JournalsContext())
            {
                db.Users.Remove(user);
                db.SaveChanges();
            }
        }
Ejemplo 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);
        }