Ejemplo n.º 1
0
        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 UserFunctionMenuScreen(string currentUsernameRole)
        {
            var    _db          = new ConnectToServer();
            string currentUser  = _db.RetrieveCurrentUserFromDatabase();
            int    countTickets = _db.CountOpenTicketsAssignedToUser(currentUser);

            string notificationsAdmin = $"Check user notifications";
            string notificationsUser  = $"Check user notifications [{countTickets}]";
            string requests           = "Create new username/password from requests";
            string viewUsers          = "Show list of active users";
            string modifyRole         = "Upgrade/Downgrade user's role";
            string deleteUser         = "******";
            string manageTickets      = "Manage Customer Trouble Tickets";
            string viewTickets        = "View Trouble Tickets";
            string editTicket         = "Edit Trouble Tickets";
            string deleteTicket       = "Delete Trouble Tickets";
            string logOut             = "\nLog Out";
            string message            = "\nChoose one of the following functions\n";

            //Active User Functions. Control of actions is maintained by excluding a user from certain methods.
            switch (currentUsernameRole)
            {
                #region Super Admin Functions
            case "super_admin":
                while (true)
                {
                    string SuperAdminFunctionMenu = SelectMenu.MenuColumn(new List <string> {
                        notificationsAdmin, requests, viewUsers, modifyRole, deleteUser, manageTickets, viewTickets, editTicket, deleteTicket, logOut
                    }, currentUser, message).option;

                    if (SuperAdminFunctionMenu == notificationsAdmin)
                    {
                        CheckNotifications.CheckAdminNotifications();
                    }

                    else if (SuperAdminFunctionMenu == requests)
                    {
                        SuperAdminFunctions.CreateNewUserFromRequestFunction();
                    }

                    else if (SuperAdminFunctionMenu == viewUsers)
                    {
                        SuperAdminFunctions.ShowAvailableUsersFunction();
                    }

                    else if (SuperAdminFunctionMenu == modifyRole)
                    {
                        SuperAdminFunctions.AlterUserRoleStatus();
                    }

                    else if (SuperAdminFunctionMenu == deleteUser)
                    {
                        SuperAdminFunctions.DeleteUserFromDatabase();
                    }

                    else if (SuperAdminFunctionMenu == manageTickets)
                    {
                        ManageTroubleTickets.OpenOrCloseTroubleTicket();
                    }

                    else if (SuperAdminFunctionMenu == viewTickets)
                    {
                        ViewExistingTickets.ViewExistingOpenTicketsFunction();
                    }

                    else if (SuperAdminFunctionMenu == editTicket)
                    {
                        EditExistingTroubleTickets.EditOpenTicket();
                    }

                    else if (SuperAdminFunctionMenu == deleteTicket)
                    {
                        DeleteTroubleTickets.DeleteExistingOpenOrClosedTicketFunction();
                    }

                    else if (SuperAdminFunctionMenu == logOut)
                    {
                        _db.LoggingOffQuasar();
                    }
                }
                #endregion

                #region Administrator Functions
            case "Administrator":
                while (true)
                {
                    string AdminFunctionMenu = SelectMenu.MenuColumn(new List <string> {
                        notificationsUser, manageTickets, viewTickets, editTicket, deleteTicket, logOut
                    }, currentUser, message).option;

                    if (AdminFunctionMenu == notificationsUser)
                    {
                        CheckNotifications.CheckUserNotifications();
                    }

                    else if (AdminFunctionMenu == manageTickets)
                    {
                        ManageTroubleTickets.OpenOrCloseTroubleTicket();
                    }

                    else if (AdminFunctionMenu == viewTickets)
                    {
                        ViewExistingTickets.ViewExistingOpenTicketsFunction();
                    }

                    else if (AdminFunctionMenu == editTicket)
                    {
                        EditExistingTroubleTickets.EditOpenTicket();
                    }

                    else if (AdminFunctionMenu == deleteTicket)
                    {
                        DeleteTroubleTickets.DeleteExistingOpenOrClosedTicketFunction();
                    }

                    else if (AdminFunctionMenu == logOut)
                    {
                        _db.LoggingOffQuasar();
                    }
                }
                #endregion

                #region Moderator Functions
            case "Moderator":
                while (true)
                {
                    string ModeratorFunctionMenu = SelectMenu.MenuColumn(new List <string> {
                        notificationsUser, manageTickets, viewTickets, editTicket, logOut
                    }, currentUser, message).option;

                    if (ModeratorFunctionMenu == notificationsUser)
                    {
                        CheckNotifications.CheckUserNotifications();
                    }

                    else if (ModeratorFunctionMenu == manageTickets)
                    {
                        ManageTroubleTickets.OpenOrCloseTroubleTicket();
                    }

                    else if (ModeratorFunctionMenu == viewTickets)
                    {
                        ViewExistingTickets.ViewExistingOpenTicketsFunction();
                    }

                    else if (ModeratorFunctionMenu == editTicket)
                    {
                        EditExistingTroubleTickets.EditOpenTicket();
                    }

                    else if (ModeratorFunctionMenu == logOut)
                    {
                        _db.LoggingOffQuasar();
                    }
                }
                #endregion

                #region User Functions
            case "User":
                while (true)
                {
                    string UserFunctionMenu = SelectMenu.MenuColumn(new List <string> {
                        notificationsUser, manageTickets, viewTickets, logOut
                    }, currentUser, message).option;

                    if (UserFunctionMenu == notificationsUser)
                    {
                        CheckNotifications.CheckUserNotifications();
                    }

                    else if (UserFunctionMenu == manageTickets)
                    {
                        ManageTroubleTickets.OpenOrCloseTroubleTicket();
                    }

                    else if (UserFunctionMenu == viewTickets)
                    {
                        ViewExistingTickets.ViewExistingOpenTicketsFunction();
                    }

                    else if (UserFunctionMenu == logOut)
                    {
                        _db.LoggingOffQuasar();
                    }
                }
                #endregion
            }
        }