public static void CheckAdminNotifications()
        {
            string currentUsername     = _db.RetrieveCurrentUserFromDatabase();
            string currentUsernameRole = _db.RetrieveCurrentUsernameRoleFromDatabase();

            print.QuasarScreen(currentUsername);
            print.UniversalLoadingOutput("Loading");
            string pendingUsernameCheck = _text.GetPendingUsername();

            if (pendingUsernameCheck == " ")
            {
                Console.WriteLine("There are no pending User registrations\n\n(Press any key to continue)");
                Console.ReadKey();
                ActiveUserFunctions.UserFunctionMenuScreen(currentUsernameRole);
            }
            else
            {
                string yes              = "Yes";
                string no               = "No";
                string requestMsg       = "\r\nYou have 1 pending User registration request. Would you like to create new user?\n";
                string yesOrNoSelection = SelectMenu.MenuRow(new List <string> {
                    yes, no
                }, currentUsername, requestMsg).option;

                if (yesOrNoSelection == yes)
                {
                    SuperAdminFunctions.CreateNewUserFromRequestFunction();
                }
                else if (yesOrNoSelection == no)
                {
                    ActiveUserFunctions.UserFunctionMenuScreen(currentUsernameRole);
                }
            }
        }
        public static void CloseCustomerTicketFunction()
        {
            string currentUsername        = _db.RetrieveCurrentUserFromDatabase();
            int    ticketID               = print.SelectTicketID();
            string previousUserAssignedTo = _db.SelectUserAssignedToTicket(ticketID);

            if (_db.CheckIfTicketIDWithStatusOpenExistsInList(ticketID) == false)
            {
                print.ColoredText($"There is no Customer Ticket with [ID = {ticketID}]\n\n(Press any key to continue)", ConsoleColor.DarkRed);
                Console.ReadKey();
                ManageTroubleTickets.OpenOrCloseTroubleTicket();
            }
            else
            {
                string yes            = "Yes";
                string no             = "No";
                string closeTicket    = $"Are you sure you want to mark ticket {ticketID} as closed?\r\n";
                string optionYesOrNo2 = SelectMenu.MenuRow(new List <string> {
                    yes, no
                }, currentUsername, closeTicket).option;

                if (optionYesOrNo2 == yes)
                {
                    _db.SetTicketStatusToClosed(currentUsername, ticketID);
                    _text.CloseTicketToUserNotification(currentUsername, previousUserAssignedTo, ticketID);
                    ManageTroubleTickets.OpenOrCloseTroubleTicket();
                }
                else if (optionYesOrNo2 == no)
                {
                    ManageTroubleTickets.OpenOrCloseTroubleTicket();
                }
            }
        }
        public static string AssignTicketToUser()
        {
            string currentUsername = _db.RetrieveCurrentUserFromDatabase();
            string assignTicket    = "Would you like to assign the ticket to another user?\r\n";
            string yes             = "Yes";
            string no = "No";
            string yesOrNoSelection = SelectMenu.MenuRow(new List <string> {
                yes, no,
            }, currentUsername, assignTicket).option;

            if (yesOrNoSelection == yes)
            {
                print.QuasarScreen(currentUsername);
                print.UniversalLoadingOutput("Loading");

                Dictionary <string, string> AvailableUsernamesDictionary = _db.ShowAvailableUsersFromDatabase();
                Console.Write("\r\nPlease select a user and proceed to assign: ");
                string usernameAssignment = InputControl.UsernameInput();

                while (AvailableUsernamesDictionary.ContainsKey(usernameAssignment) == false || usernameAssignment == "admin")
                {
                    if (AvailableUsernamesDictionary.ContainsKey(usernameAssignment) == false)
                    {
                        print.ColoredText($"Database does not contain a User {usernameAssignment}.\n\n(Press any key to continue)", ConsoleColor.DarkRed);
                        Console.ReadKey();
                        print.QuasarScreen(currentUsername);
                        AvailableUsernamesDictionary = _db.ShowAvailableUsersFromDatabase();
                        Console.Write("\r\n\nPlease select a user and proceed to assign: ");
                        usernameAssignment = InputControl.UsernameInput();
                    }
                    else
                    {
                        print.ColoredText("Cannot assign ticket to super_admin! Please choose a different user.\n\n(Press any key to continue)", ConsoleColor.DarkRed);
                        Console.ReadKey();
                        print.QuasarScreen(currentUsername);
                        AvailableUsernamesDictionary = _db.ShowAvailableUsersFromDatabase();
                        Console.Write("\r\nPlease select a user and proceed to assign: ");
                        usernameAssignment = InputControl.UsernameInput();
                    }
                }
                _text.AssignTicketToUserNotification(currentUsername, usernameAssignment);
                return(usernameAssignment);
            }

            else if (yesOrNoSelection == no)
            {
                return(currentUsername);
            }
            return(currentUsername);
        }
Exemplo n.º 4
0
        //Handles creation/deleting/viewing/editing of users by super_admin
        public static void CreateNewUserFromRequestFunction()
        {
            string currentUsername     = _db.RetrieveCurrentUserFromDatabase();
            string currentUsernameRole = _db.RetrieveCurrentUsernameRoleFromDatabase();
            string pendingUsername     = _text.GetPendingUsername();

            if (pendingUsername == " ")
            {
                print.UniversalLoadingOutput("Action in progress");
                Console.Write("There are no pending requests.\n\n(Press any key to continue)");
                Console.ReadKey();
                ActiveUserFunctions.UserFunctionMenuScreen(currentUsernameRole);
            }
            else
            {
                pendingUsername = pendingUsername.Remove(0, 10);
                string pendingPassphrase = _text.GetPendingPassphrase().Remove(0, 12);
                string yes              = "Yes";
                string no               = "No";
                string createUserMsg    = $"\r\nYou are about to create a new entry :\nUsername: {pendingUsername} - Password: {pendingPassphrase}\n\nWould you like to proceed?\n\n";
                string yesOrNoSelection = SelectMenu.MenuRow(new List <string> {
                    yes, no
                }, currentUsername, createUserMsg).option;

                if (yesOrNoSelection == yes)
                {
                    string pendingRole = print.SelectUserRole();

                    _db.InsertNewUserIntoDatabase(pendingUsername, pendingPassphrase, pendingRole);
                    print.QuasarScreen(currentUsername);
                    print.UniversalLoadingOutput("Creating new user in progress");

                    _text.ClearNewUserRegistrationList();
                    _text.CreateNewUserLogFile(pendingUsername);

                    print.ColoredText($"User {pendingUsername} has been created successfully. Status : {pendingRole}.\n\n(Press any key to continue)", ConsoleColor.DarkGreen);
                    Console.ReadKey();
                    ActiveUserFunctions.UserFunctionMenuScreen(currentUsernameRole);
                }
                else if (yesOrNoSelection == no)
                {
                    ActiveUserFunctions.UserFunctionMenuScreen(currentUsernameRole);
                }
            }
        }
Exemplo n.º 5
0
        public void LoggingOffQuasar()
        {
            string yes              = "Yes";
            string no               = "No";
            string logOffMessage    = "Would you like to log out?\r\n";
            string currentUsername  = RetrieveCurrentUserFromDatabase();
            string yesOrNoSelection = SelectMenu.MenuRow(new List <string> {
                yes, no
            }, currentUsername, logOffMessage).option;

            if (yesOrNoSelection == yes)
            {
                print.QuasarScreen("Not Registered");
                SetCurrentUserStatusToInactive(currentUsername);
                ApplicationMenu.LoginScreen();
            }
            else if (yesOrNoSelection == no)
            {
                ActiveUserFunctions.UserFunctionMenuScreen(RetrieveCurrentUsernameRoleFromDatabase());
            }
        }
Exemplo n.º 6
0
        public void TerminateQuasar()
        {
            var    print            = new OutputControl();
            string yes              = "Yes";
            string no               = "No";
            string currentUsername  = "******";
            string exitMessage      = "\r\nWould you like to exit Quasar?\r\n";
            string yesOrNoSelection = SelectMenu.MenuRow(new List <string> {
                yes, no
            }, currentUsername, exitMessage).option;

            if (yesOrNoSelection == yes)
            {
                SetCurrentUserStatusToInactive(currentUsername);
                print.UniversalLoadingOutput("Wait for Quasar to shut down");
                print.SpecialThanksMessage();
                Environment.Exit(0);
            }
            else if (yesOrNoSelection == no)
            {
                ApplicationMenu.LoginScreen();
            }
        }