public static void ChangeUsername(User oldU, string newU, string currentU)
        {
            using (var db = new PostingContext())
            {
                if (oldU.Username == currentU)
                {
                    Console.WriteLine("Current User cannot delete himself");
                }
                else
                {
                    User oldUser = new User();
                    oldUser = oldUser.PullUser(oldU.Username);

                    User newUser = new User()
                    {
                        Username = newU, Password = oldUser.Password, Role = oldUser.Role
                    };
                    db.Users.Remove(oldUser);
                    db.Users.Add(newUser);


                    db.SaveChanges();
                }
            }
        }
 //Insert new Super Admin
 public static void InsertSuperAdmin(SuperAdmin user)
 {
     using (var db = new PostingContext())
     {
         db.Users.Add(user);
         db.SaveChanges();
     }
 }
 public static void DeletePost(int id)
 {
     using (var db = new PostingContext()){
         var post = db.Posts.FirstOrDefault(p => p.Id == id);
         db.Posts.Remove(post);
         db.SaveChanges();
     }
 }
        //--------------------------------  POSTS  ------------------------------------------------------

        //Insert new Post
        public static void NewPost(Post post)
        {
            using (var db = new PostingContext())
            {
                db.Posts.Add(post);
                db.SaveChanges();
            }
        }
 //----------------------  Insert new Users about demo objects ------------------------------------------
 public static void InsertSimpleUser(SimpleUser user)
 {
     using (var db = new PostingContext())
     {
         db.Users.Add(user);
         db.SaveChanges();
     }
 }
 //--------------------------  Users' Roles     -----------------------------------------------
 public static void ChangeRoles(string username, string Role)
 {
     using (var db = new PostingContext())
     {
         var user = db.Users.FirstOrDefault(u => u.Username == username);
         user.Role = Role;
         db.SaveChanges();
     }
 }
        //--------------------   Insert new Users for App.cs ---------------------------------------------

        public static void InsertNewSimpleUser(string username, string password)
        {
            var user = new SimpleUser {
                Username = username, Password = password, Role = "SimpleUser"
            };

            using (var db = new PostingContext())
            {
                db.Users.Add(user);
                db.SaveChanges();
            }
        }
        public void InsertNewAdmin(string username, string password)
        {
            var user = new SuperAdmin {
                Username = username, Password = password
            };


            using (var db = new PostingContext())
            {
                db.Users.Add(user);
                db.SaveChanges();
            }
        }
        public static bool EditPost(int id, string message)
        {
            bool result = false;

            result = FindPost(id);
            if (result)
            {
                using (var db = new PostingContext())
                {
                    var post = db.Posts.Where(p => p.Id == id).FirstOrDefault();
                    post.Message         = message;
                    post.ConditionEdited = true;
                    db.SaveChanges();
                }
                return(true);
            }
            return(false);
        }
        public static void ChangePassword(string name, string pass)
        {
            using (var db = new PostingContext())
            {
                if (DBCommands.FindUser(name))
                {
                    var user = db.Users.Where(u => u.Username == name).FirstOrDefault();
                    //DBCommands.
                    user.Password = pass;

                    db.SaveChanges();
                }
                else
                {
                    Console.WriteLine("Changing password was cancelled.Please try again and use a unique username.");
                }
            }
        }
 public static void DeleteUser(string deleteUser, string user)
 {
     using (var db = new PostingContext())
     {
         if (DBCommands.FindUser(deleteUser))
         {
             if (deleteUser == user)
             {
                 Console.WriteLine("The current user cannot be deleted!!");
             }
             else
             {
                 var duser = db.Users.FirstOrDefault(u => u.Username == deleteUser);
                 db.Users.Remove(duser);
                 db.SaveChanges();
             }
         }
         else
         {
             Console.WriteLine("Changing username was cancelled.Please try again and use a unique username.");
         }
     }
 }