Beispiel #1
0
        public static void ManageUsers(UserManager activeUserManager)
        {
            List <string> ChangeUserMenuItems = new List <string> {
                "Permissions", "Delete User", "Create a NEW User", "Back"
            };
            string manageUsersChoice = Menus.VerticalMenu(StringsFormatted.ManageUsers, ChangeUserMenuItems);

            if (manageUsersChoice.Contains("Create"))
            {
                ManageUserFunctions.CreateNewUser();
                return;
            }
            else if (manageUsersChoice.Contains("Back"))
            {
                return;
            }
            User receiver = ManageUserFunctions.SelectUser(activeUserManager);

            if (receiver is null)
            {
                return;
            }
            if (manageUsersChoice == "Delete User")
            {
                ManageUserFunctions.DeleteUser(receiver);
            }
            else if (manageUsersChoice == "Permissions")
            {
                ManageUserFunctions.ChangeUserPermissions(receiver);
            }
        }
Beispiel #2
0
        public static void ForwardMessage(UserManager activeUserManager, Message forwardMessage)
        {
            User receiver = ManageUserFunctions.SelectUser(activeUserManager);

            if (receiver is null)
            {
                return;
            }
            string  forwardTitle     = "FW: " + forwardMessage.Title;
            string  forwardBody      = forwardMessage.Body;
            Message forwardedMessage = new Message(activeUserManager.TheUser.Id, receiver.Id, forwardTitle, forwardBody);

            using (var database = new DatabaseStuff())
            {
                database.Messages.Add(forwardedMessage);
                database.SaveChanges();
            }
            Console.Clear();
            Console.WriteLine($"\n\n\tMessage successfully forwarded to {receiver.UserName}\n\n\tOK");
            Console.ReadKey();
        }
Beispiel #3
0
        public static void SendEmail(UserManager activeUserManager, User receiver = null, string replyTitle = "")
        {
            string title = "\n\n\tTitle: " + replyTitle;

            // NULL Receiver means it's NOT a REPLY it's just a NEW message.
            if (receiver is null)
            {
                receiver = ManageUserFunctions.SelectUser(activeUserManager);
            }
            if (receiver is null)
            {
                return;
            }

            Console.WriteLine(StringsFormatted.SendEmail);
            Console.Write(title);

            string MessageTitle = (title.Contains("RE")) ? replyTitle : Console.ReadLine();

            Console.Write("\n\tBody: ");
            string MessageBody = Console.ReadLine();

            using (var database = new DatabaseStuff())
            {
                int     senderId = database.Users.Single(i => i.UserName == activeUserManager.UserName).Id;
                Message email    = new Message(senderId, receiver.Id, MessageTitle, MessageBody);
                try
                {
                    database.Messages.Add(email);
                    database.SaveChanges();
                    Console.Write($"\n\n\tEmail sent successfully to {receiver.UserName}\n\n\tOK");
                }
                catch (Exception e) { MenuFunctions.PrintException(e); }
                Console.ReadKey();
            }
        }