Beispiel #1
0
        private static void DeleteExistingOpenOrClosedTicketSubFunction()
        {
            string currentUsername     = _db.RetrieveCurrentUserFromDatabase();
            string currentUsernameRole = _db.RetrieveCurrentUsernameRoleFromDatabase();
            int    ticketID            = print.SelectTicketID();
            string previousTicketOwner = _db.SelectUserAssignedToTicket(ticketID);

            if (_db.CheckIfTicketIDWithStatusOpenOrClosedExistsInList(ticketID) == false)
            {
                print.ColoredText($"There is no Customer Ticket with [ID = {ticketID}]\n\n(Press any key to continue)", ConsoleColor.DarkRed);
                Console.ReadKey();
                ActiveUserFunctions.UserFunctionMenuScreen(currentUsernameRole);
            }

            string yes             = "Yes";
            string no              = "No";
            string deleteTicketMsg = $"Are you sure you want to delete ticket {ticketID}? Action cannot be undone.\r\n";
            string optionYesOrNo2  = SelectMenu.MenuColumn(new List <string> {
                yes, no
            }, currentUsername, deleteTicketMsg).option;

            if (optionYesOrNo2 == yes)
            {
                _db.DeleteCustomerTicket(currentUsername, ticketID);
                _text.DeleteTicketToUserNotification(currentUsername, previousTicketOwner, ticketID);
                ActiveUserFunctions.UserFunctionMenuScreen(currentUsernameRole);
            }
            else if (optionYesOrNo2 == no)
            {
                ActiveUserFunctions.UserFunctionMenuScreen(currentUsernameRole);
            }
        }
Beispiel #2
0
        public static void LoginScreen()
        {
            var _db = new ConnectToServer();

            string login       = "******";
            string register    = "New Account request";
            string quit        = "Quit Quasar";
            string currentUser = "******";
            string loginMsg    = "\r\nWelcome to Quasar! Choose one of the following options to continue:\r\n";

            while (true)
            {
                string LoginRegisterQuit = SelectMenu.MenuColumn(new List <string> {
                    login, register, quit
                }, currentUser, loginMsg).option;

                if (LoginRegisterQuit == login)
                {
                    _db.UserLoginCredentials();
                }
                else if (LoginRegisterQuit == register)
                {
                    CreateNewAccount.CreateNewAccountRequest();
                }
                else if (LoginRegisterQuit == quit)
                {
                    _db.TerminateQuasar();
                }
            }
        }
Beispiel #3
0
        public static void DeleteExistingOpenOrClosedTicketFunction()
        {
            string currentUsername     = _db.RetrieveCurrentUserFromDatabase();
            string currentUsernameRole = _db.RetrieveCurrentUsernameRoleFromDatabase();

            print.QuasarScreen(currentUsername);
            print.UniversalLoadingOutput("Loading");
            Console.WriteLine("DELETE EXISTING TECHNICAL TICKETS");

            string viewList         = "View List of Tickets";
            string back             = "\r\nBack";
            string closeSpecific    = "Delete Specific Ticket";
            string deleteTicketsMsg = "Choose one of the following functions\r\n";

            while (true)
            {
                string deleteTickets = SelectMenu.MenuColumn(new List <string> {
                    viewList, closeSpecific, back
                }, currentUsername, deleteTicketsMsg).option;
                if (deleteTickets == viewList)
                {
                    _db.ViewListOfAllCustomerTickets();
                    DeleteExistingOpenOrClosedTicketSubFunction();
                }
                else if (deleteTickets == closeSpecific)
                {
                    DeleteExistingOpenOrClosedTicketSubFunction();
                }
                else if (deleteTickets == back)
                {
                    ActiveUserFunctions.UserFunctionMenuScreen(currentUsernameRole);
                }
            }
        }
        private static void EditTicketOptions(int ID)
        {
            string currentUsername     = _db.RetrieveCurrentUserFromDatabase();
            string currentUsernameRole = _db.RetrieveCurrentUsernameRoleFromDatabase();

            string edit    = "Edit Ticket Comment";
            string assign  = "Edit Ticket's User assignment";
            string back    = "\r\nBack";
            string editMsg = "\r\nChoose one of the following options to continue:\r\n";

            while (true)
            {
                string EditCommentAndAssignment = SelectMenu.MenuColumn(new List <string> {
                    edit, assign, back
                }, currentUsername, editMsg).option;

                if (EditCommentAndAssignment == edit)
                {
                    string ticketComment = print.TicketComment();
                    _db.EditCommentOfOpenTicket(ID, ticketComment);
                }
                else if (EditCommentAndAssignment == assign)
                {
                    string newUserAssignment = AssignTroubleTickets.AssignTicketToUser();
                    AssignTroubleTickets.ChangeUserAssignmentToOpenTicket(ID, newUserAssignment);
                }
                else if (EditCommentAndAssignment == back)
                {
                    print.QuasarScreen(currentUsername);
                    ActiveUserFunctions.UserFunctionMenuScreen(currentUsernameRole);
                }
            }
        }
        public string SelectUserRole()
        {
            var _db = new ConnectToServer();

            string administrator = "Administrator";
            string moderator     = "Moderator";
            string user          = "******";
            string selectionMsg  = "\r\nChoose one of the following User Roles:\r\n";
            string currentUser   = _db.RetrieveCurrentUserFromDatabase();

            while (true)
            {
                string SelectUserRoleFromList = SelectMenu.MenuColumn(new List <string> {
                    administrator, moderator, user
                }, currentUser, selectionMsg).option;

                if (SelectUserRoleFromList == administrator)
                {
                    return(administrator);
                }
                else if (SelectUserRoleFromList == moderator)
                {
                    return(moderator);
                }
                else if (SelectUserRoleFromList == user)
                {
                    return(user);
                }
            }
        }
Beispiel #6
0
        public static void OpenOrCloseTroubleTicket()
        {
            var    _db                 = new ConnectToServer();
            string currentUsername     = _db.RetrieveCurrentUserFromDatabase();
            string currentUsernameRole = _db.RetrieveCurrentUsernameRoleFromDatabase();
            string open                = "Open new Customer Ticket";
            string close               = "Close Customer Ticket";
            string back                = "\r\nBack";
            string manageTicketmsg     = "\r\nChoose one of the following options to continue:\r\n";

            while (true)
            {
                string openCloseTicketMsg = SelectMenu.MenuColumn(new List <string> {
                    open, close, back
                }, currentUsername, manageTicketmsg).option;

                if (openCloseTicketMsg == open)
                {
                    OpenNewTroubleTicket.OpenTicket();
                }

                else if (openCloseTicketMsg == close)
                {
                    CloseExistingTroubleTickets.CloseTicket();
                }

                else if (openCloseTicketMsg == back)
                {
                    ActiveUserFunctions.UserFunctionMenuScreen(currentUsernameRole);
                }
            }
        }
        public static void EditOpenTicket()
        {
            string currentUsername     = _db.RetrieveCurrentUserFromDatabase();
            string currentUsernameRole = _db.RetrieveCurrentUsernameRoleFromDatabase();

            print.QuasarScreen(currentUsername);
            print.UniversalLoadingOutput("Loading");
            Console.WriteLine("EDIT OPEN TECHNICAL TICKET");

            string listTicketsMsg = "Choose one of the following options\r\n";
            string viewList       = "View Trouble Ticket List";
            string viewSpecific   = "Edit Specific Trouble Ticket";
            string back           = "\r\nBack";

            while (true)
            {
                string editTicket = SelectMenu.MenuColumn(new List <string> {
                    viewList, viewSpecific, back
                }, currentUsername, listTicketsMsg).option;
                if (editTicket == viewList)
                {
                    _db.ViewListOfOpenCustomerTickets();
                    EditOpenTicketSubFunction();
                }
                else if (editTicket == viewSpecific)
                {
                    EditOpenTicketSubFunction();
                }
                else if (editTicket == back)
                {
                    print.QuasarScreen(currentUsername);
                    ActiveUserFunctions.UserFunctionMenuScreen(currentUsernameRole);
                }
            }
        }
        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 void CloseTicket()
        {
            string currentUsername = _db.RetrieveCurrentUserFromDatabase();

            print.QuasarScreen(currentUsername);
            print.UniversalLoadingOutput("Loading");
            Console.WriteLine("CLOSE EXISTING TECHNICAL TICKETS");

            string viewList      = "View List of Open Tickets";
            string back          = "\r\nBack";
            string closeSpecific = "Close Specific Ticket";
            string optionsMsg    = "Choose one of the following functions\r\n";

            while (true)
            {
                string optionYesOrNo = SelectMenu.MenuColumn(new List <string> {
                    viewList, closeSpecific, back
                }, currentUsername, optionsMsg).option;
                if (optionYesOrNo == viewList)
                {
                    _db.ViewListOfOpenCustomerTickets();
                    CloseCustomerTicketFunction();
                }
                else if (optionYesOrNo == closeSpecific)
                {
                    CloseCustomerTicketFunction();
                }
                else if (optionYesOrNo == back)
                {
                    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);
        }
Beispiel #12
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);
                }
            }
        }
        public static void CheckUserNotifications()
        {
            string currentUsername     = _db.RetrieveCurrentUserFromDatabase();
            string currentUsernameRole = _db.RetrieveCurrentUsernameRoleFromDatabase();

            print.QuasarScreen(currentUsername);
            print.UniversalLoadingOutput("Loading");

            int    countTickets      = _db.CountOpenTicketsAssignedToUser(currentUsername);
            string showListOfTickets = "Show List of Tickets";
            string back = "\r\nBack";
            string showNotificationsLog = "Show notifications Log";
            string openListMsg          = $"There are [{countTickets}] open Trouble Tickets assigned to you.\r\nHow would you like to proceed?";

            string viewNotificationsList = SelectMenu.MenuColumn(new List <string> {
                showListOfTickets, showNotificationsLog, back
            }, currentUsername, openListMsg).option;

            if (viewNotificationsList == showListOfTickets)
            {
                if (countTickets == 0)
                {
                    Console.WriteLine("\r\nYou do not have any Tickets assigned to you.\n\n(Press any key to continue)");
                    Console.ReadKey();
                }
                else
                {
                    _db.SelectOpenTicketsAssignedToUser(currentUsername);
                    Console.WriteLine("(Press any key to continue)");
                    Console.ReadKey();
                    CheckUserNotifications();
                }
            }
            else if (viewNotificationsList == showNotificationsLog)
            {
                _text.ViewUserNotificationsLog(currentUsername);
                Console.WriteLine("(Press any key to continue)");
                Console.ReadKey();
                CheckUserNotifications();
            }
            else if (viewNotificationsList == back)
            {
                ActiveUserFunctions.UserFunctionMenuScreen(currentUsernameRole);
            }
        }
        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());
            }
        }
        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();
            }
        }
        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
            }
        }