Exemplo n.º 1
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);
                }
            }
        }
Exemplo n.º 2
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);
            }
        }
        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);
                }
            }
        }
        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);
                }
            }
        }
Exemplo n.º 5
0
        public static void DeleteUserFromDatabase()
        {
            string currentUsername     = _db.RetrieveCurrentUserFromDatabase();
            string currentUsernameRole = _db.RetrieveCurrentUsernameRoleFromDatabase();

            print.QuasarScreen(currentUsername);
            print.UniversalLoadingOutput("Loading");
            Console.WriteLine("\r\nChoose a User from the list and proceed to delete.");
            Dictionary <string, string> AvailableUsernamesDictionary = _db.ShowAvailableUsersFromDatabase();

            string username = InputControl.UsernameInput();

            while (AvailableUsernamesDictionary.ContainsKey(username) == false || username == "admin")
            {
                print.QuasarScreen(currentUsername);
                if (AvailableUsernamesDictionary.ContainsKey(username) == false)
                {
                    print.ColoredText($"\nDatabase does not contain a User {username}. Please select a different user.", ConsoleColor.DarkRed);
                }
                else
                {
                    print.ColoredText("\nCannot delete super_admin! Please choose a different user.", ConsoleColor.DarkRed);
                }
                Console.WriteLine("\r\nChoose a User from the list and proceed to delete.");
                AvailableUsernamesDictionary = _db.ShowAvailableUsersFromDatabase();
                username = InputControl.UsernameInput();
            }
            _db.RemoveUsernameFromDatabase(username);
            print.QuasarScreen(currentUsername);
            print.UniversalLoadingOutput("Deleting existing user in progress");
            _text.DeleteUserNotificationsLog(username);
            print.ColoredText($"\nUsername {username} has been successfully deleted from database.\n\n(Press any key to continue)", ConsoleColor.DarkGreen);
            Console.ReadKey();
            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);
                }
            }
        }
Exemplo n.º 7
0
        public void UserLoginCredentials()
        {
            print.QuasarScreen("Not Registered");
            string username   = InputControl.UsernameInput();
            string passphrase = InputControl.PassphraseInput();
            var    dbcon      = new SqlConnection(Globals.connectionString);

            while (TestConnectionToSqlServer(dbcon))
            {
                if (CheckUsernameAndPasswordMatchInDatabase(username, passphrase))
                {
                    SetCurrentUserStatusToActive(username);
                    print.QuasarScreen(username);
                    print.ColoredText($"Connection Established! Welcome back {username}!", ConsoleColor.DarkGreen);
                    System.Threading.Thread.Sleep(1500);
                    ActiveUserFunctions.UserFunctionMenuScreen(RetrieveCurrentUsernameRoleFromDatabase());
                }
                else
                {
                    print.QuasarScreen("Not Registered");
                    print.ColoredText($"\r\nInvalid Username or Passphrase. Try again.\n\n(press any key to continue)", ConsoleColor.DarkRed);
                    Console.ReadKey();
                    UserLoginCredentials();
                }
            }
        }
Exemplo n.º 8
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);
                }
            }
        }
Exemplo n.º 9
0
        public static void ShowAvailableUsersFunction()
        {
            string currentUsername     = _db.RetrieveCurrentUserFromDatabase();
            string currentUsernameRole = _db.RetrieveCurrentUsernameRoleFromDatabase();

            print.QuasarScreen(currentUsername);
            print.UniversalLoadingOutput("Loading");
            _db.ShowAvailableUsersFromDatabase();
            Console.Write("\r\nPress any key to return to Functions menu");
            Console.ReadKey();
            ActiveUserFunctions.UserFunctionMenuScreen(currentUsernameRole);
        }
Exemplo n.º 10
0
        private static void ViewExistingOpenTicketsSubFunction()
        {
            string currentUsernameRole = _db.RetrieveCurrentUsernameRoleFromDatabase();
            int    TicketID            = print.SelectTicketID();

            if (_db.CheckIfTicketIDWithStatusOpenExistsInList(TicketID) == false)
            {
                print.ColoredText($"There is no Customer Ticket with [ID = {TicketID}]\n\n(Press any key to go back to Main Menu)", ConsoleColor.DarkRed);
                Console.ReadKey();
                ActiveUserFunctions.UserFunctionMenuScreen(currentUsernameRole);
            }
            ViewSingleCustomerTicket(TicketID);
            ActiveUserFunctions.UserFunctionMenuScreen(currentUsernameRole);
        }
Exemplo n.º 11
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.º 12
0
        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);
            }
        }
Exemplo n.º 13
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());
            }
        }