Esempio n. 1
0
        static void Main(string[] args)
        {
            while (true)
            {
                int         Menuchoice;
                List <User> Users   = new List <User>();
                UserManager Manager = new UserManager();
                //edo perno apo to db olous tous users se mia lista
                Users = Manager.GetAllUsers();
                //Console.WriteLine("1.Login");
                //Console.WriteLine("2.Create new user");
                //Console.WriteLine("3.Exit");
                //Menuchoice = Convert.ToInt32(Console.ReadLine());
                List <string> MenuList = new List <string>()
                {
                    "Login", "Create new user", "Exit"
                };
                PrintsForMenuScreen s = new PrintsForMenuScreen(MenuList);
                Menuchoice = s.ArrowsForFirstScreen(MenuList);

                if (Menuchoice == 1)
                {
                    LoginScreen Login = new LoginScreen();
                    Login.GotoLoginScreen();
                }
                else if (Menuchoice == 2)
                {
                    Createuser user = new Createuser();
                    user.TakeUsers(Users);
                    //foreach (var User in Users)
                    //{
                    //    Console.WriteLine(User.UserName + " " + User.Password);
                    //}

                    //edo emfanizo olous tous users apo to db

                    //foreach (var userobject in Users)
                    //{
                    //    Console.WriteLine(userobject.Id+" "+ userobject.UserName);
                    //}
                }
                else if (Menuchoice == 3)
                {
                    Environment.Exit(0);
                }
            }
        }
Esempio n. 2
0
        public int ArrowsForFirstScreen(List <Message> MenuList)
        {
            foreach (var item in MenuList)
            {
                mylistOfUsers.Add(item.Text + " " + item.SenderId);
            }
            MaxMenuChoises = MenuList.Count();
            ConsoleKeyInfo      keyinfo;
            PrintsForMenuScreen p = new PrintsForMenuScreen(MenuList);
            int MenuLevel         = 1;

            p.PrintsFor(MenuLevel);

            do
            {
                // p.PrintsFor(MenuLevel);
                keyinfo = Console.ReadKey();
                if (keyinfo.Key == ConsoleKey.DownArrow && MenuLevel == MaxMenuChoises)
                {
                    MenuLevel = 1;
                    p.PrintsFor(MenuLevel);
                }
                else if (keyinfo.Key == ConsoleKey.DownArrow)//&& MenuLevel == 1
                {
                    MenuLevel++;
                    p.PrintsFor(MenuLevel);
                }
                else if (keyinfo.Key == ConsoleKey.UpArrow && MenuLevel == 1)  // && mylist[2] != "0"
                {
                    MenuLevel = MaxMenuChoises;
                    p.PrintsFor(MenuLevel);
                }
                else if (keyinfo.Key == ConsoleKey.UpArrow)// && MenuLevel == 3
                {
                    MenuLevel--;
                    p.PrintsFor(MenuLevel);
                }
                p.PrintsFor(MenuLevel);
            } while (keyinfo.Key != ConsoleKey.Enter);


            return(MenuLevel);
        }
Esempio n. 3
0
        public int ArrowsForFirstScreen(List <string> MenuList)
        {
            MaxMenuChoises = MenuList.Count();
            ConsoleKeyInfo      keyinfo;
            PrintsForMenuScreen p = new PrintsForMenuScreen(MenuList);
            int MenuLevel         = 1;

            p.PrintsFor(MenuLevel);

            do
            {
                // p.PrintsFor(MenuLevel);
                keyinfo = Console.ReadKey();
                if (keyinfo.Key == ConsoleKey.DownArrow && MenuLevel == MaxMenuChoises)
                {
                    MenuLevel = 1;
                    p.PrintsFor(MenuLevel);
                }
                else if (keyinfo.Key == ConsoleKey.DownArrow)//&& MenuLevel == 1
                {
                    MenuLevel++;
                    p.PrintsFor(MenuLevel);
                }
                else if (keyinfo.Key == ConsoleKey.UpArrow && MenuLevel == 1)  // && mylist[2] != "0"
                {
                    MenuLevel = MaxMenuChoises;
                    p.PrintsFor(MenuLevel);
                }
                else if (keyinfo.Key == ConsoleKey.UpArrow)// && MenuLevel == 3
                {
                    MenuLevel--;
                    p.PrintsFor(MenuLevel);
                }
                p.PrintsFor(MenuLevel);
            } while (keyinfo.Key != ConsoleKey.Enter);


            return(MenuLevel);
        }
        public void PrintFirstScreen()
        {
            int MenuChoice = 0;

            while (MenuChoice != 4)
            {
                List <User>    _users          = new List <User>();
                List <Message> MyMessageList   = new List <Message>();
                UserManager    _listOfAllUsers = new UserManager();
                // Console.Clear();
                //Console.WriteLine("1.View all users");
                //Console.WriteLine("2.Read messages");
                //Console.WriteLine("3.Send message");
                //Console.WriteLine("4.Logout");
                //MenuChoice = Convert.ToInt32(Console.ReadLine());
                List <string> MenuList = new List <string>()
                {
                    "View all users", "Read messages", "Send message", "Logout"
                };
                PrintsForMenuScreen l = new PrintsForMenuScreen(MenuList);
                MenuChoice = l.ArrowsForFirstScreen(MenuList);
                switch (MenuChoice)
                {
                case 1:
                    //Console.Clear();
                    //PrintLogo.MessagemyWord();
                    _users = _listOfAllUsers.GetAllUsers();

                    // List<string> UsersList = new List<string>() { "View all users", "Read messages", "Send message", "Logout" };
                    PrintsForMenuScreen k = new PrintsForMenuScreen(_users);
                    k.ArrowsForFirstScreen(_users);
                    //foreach (var user in _users)
                    //{
                    //    Console.ForegroundColor = ConsoleColor.Red;
                    //    Console.WriteLine(user.Id + "." + user.UserName);
                    //}
                    break;

                case 2:
                    //Read messages
                    //Console.Clear();
                    //PrintLogo.MessagemyWord();

                    MessageManager mes = new MessageManager();
                    MyMessageList = mes.FindMessagesByUserId(StaticProperties.LoggedUserId).ToList();
                    if (MyMessageList.Count() == 0)
                    {
                        MessageBox.Show("You dont have any messages");
                        Console.WriteLine("You dont have any messages");
                    }
                    else
                    {
                        //Console.WriteLine("You have"+MyMessageList.Count()+" messages");

                        PrintsForMenuScreen o = new PrintsForMenuScreen(MyMessageList);
                        o.ArrowsForFirstScreen(MyMessageList);
                        //foreach (var mess in MyMessageList)
                        //{
                        //   Console.WriteLine(mess.Sender);
                        //   Console.WriteLine(mess.Text);
                        //}
                    }

                    //prepei na do an exo minimata pou na aforoun to diko pou id (foreing key gia tin lista me ta minimata) kai na emfaniso mia lista apo auta
                    break;

                case 3:
                    Console.Clear();
                    PrintLogo.MessagemyWord();
                    Console.Clear();
                    UserManager Receiveuser = new UserManager();

                    List <User> listofusers = new List <User>(Receiveuser.GetAllUsers());

                    PrintsForMenuScreen m = new PrintsForMenuScreen(listofusers);
                    int ReceiverId        = m.ArrowsForFirstScreen(listofusers);
                    //foreach (var user in listofusers)
                    //{
                    //    Console.WriteLine(user.Id + " " + user.UserName);
                    //}

                    //Console.WriteLine("Please select the id of the user you want to send the messsage");
                    // int ReceiverId=Convert.ToInt32( Console.ReadLine());
                    Console.WriteLine("Type your message and press enter");
                    string         text    = Console.ReadLine();
                    MessageManager message = new MessageManager();
                    message.MessageToDb(listofusers[ReceiverId - 1].Id, text, StaticProperties.LoggedUserId);

                    MessageFileLogger log = new MessageFileLogger();
                    log.LogAMessage(StaticProperties.LoggedUserName, listofusers[ReceiverId - 1].UserName, DateTime.Now, text);
                    // kano add stin lista ena minima pros ton xrhsth me id tade
                    break;
                }
            }
        }
        public static void PrintAdminLvL3FirstScreen()
        {
            int MenuChoice = 0;

            while (MenuChoice != 7)
            {
                List <User>    _users          = new List <User>();
                List <Message> MyMessageList   = new List <Message>();
                UserManager    _listOfAllUsers = new UserManager();
                List <string>  MenuList        = new List <string>()
                {
                    "View all users", "Read messages", "Send message", "Read all messages", "Edit a massage", "Delete a massage", "Logout"
                };
                PrintsForMenuScreen l = new PrintsForMenuScreen(MenuList);
                MenuChoice = l.ArrowsForFirstScreen(MenuList);

                switch (MenuChoice)
                {
                case 1:
                    _users = _listOfAllUsers.GetAllUsers();
                    PrintsForMenuScreen k = new PrintsForMenuScreen(_users);
                    k.ArrowsForFirstScreen(_users);
                    break;

                case 2:
                    MessageManager mes = new MessageManager();
                    MyMessageList = mes.FindMessagesByUserId(StaticProperties.LoggedUserId).ToList();
                    if (MyMessageList.Count() == 0)
                    {
                        MessageBox.Show("You dont have any messages");
                        Console.WriteLine("You dont have any messages");
                    }
                    else
                    {
                        PrintsForMenuScreen z = new PrintsForMenuScreen(MyMessageList);
                        z.ArrowsForFirstScreen(MyMessageList);
                    }
                    break;

                case 3:
                    Console.Clear();
                    PrintLogo.MessagemyWord();
                    Console.Clear();
                    UserManager         Receiveuser = new UserManager();
                    List <User>         listofusers = new List <User>(Receiveuser.GetAllUsers());
                    PrintsForMenuScreen m           = new PrintsForMenuScreen(listofusers);
                    int ReceiverId = m.ArrowsForFirstScreen(listofusers);
                    Console.WriteLine("Type your message and press enter");
                    string         text    = Console.ReadLine();
                    MessageManager message = new MessageManager();
                    message.MessageToDb(listofusers[ReceiverId - 1].Id, text, StaticProperties.LoggedUserId);
                    MessageFileLogger log = new MessageFileLogger();
                    log.LogAMessage(StaticProperties.LoggedUserName, listofusers[ReceiverId - 1].UserName, DateTime.Now, text);
                    break;

                case 4:
                    //read all messsages
                    Console.Clear();
                    PrintLogo.MessagemyWord();
                    Console.Clear();
                    MessageManager ReadAll        = new MessageManager();
                    List <Message> listofmessages = new List <Message>();
                    listofmessages = ReadAll.GetAllMessages();
                    PrintsForMenuScreen AllMessages = new PrintsForMenuScreen(listofmessages);
                    AllMessages.ArrowsForFirstScreen(listofmessages);
                    break;

                case 5:
                    //Edit a message
                    MessageManager      ForEdit            = new MessageManager();
                    List <Message>      AllMessagesInaList = ForEdit.GetAllMessages();
                    PrintsForMenuScreen ChooseAMessage     = new PrintsForMenuScreen(AllMessagesInaList);
                    int MessageIDForTextChange             = ChooseAMessage.ArrowsForFirstScreen(AllMessagesInaList);
                    ForEdit.EditAMessageByMessageId(AllMessagesInaList[MessageIDForTextChange - 1].Id);
                    break;

                case 6:
                    //Delete a massage
                    MessageManager      ForDelete          = new MessageManager();
                    List <Message>      AllMessagesInAList = ForDelete.GetAllMessages();
                    PrintsForMenuScreen ChooseaMessage     = new PrintsForMenuScreen(AllMessagesInAList);
                    int MessageIDForDelete = ChooseaMessage.ArrowsForFirstScreen(AllMessagesInAList);
                    ForDelete.DeleteAMessageByMessageId(AllMessagesInAList[MessageIDForDelete - 1].Id);
                    break;
                }
            }
        }
        public static void PrintAdminFirstScreen()
        {
            int MenuChoice = 0;

            while (MenuChoice != 10)
            {
                List <User>    _users          = new List <User>();
                List <Message> MyMessageList   = new List <Message>();
                UserManager    _listOfAllUsers = new UserManager();
                List <string>  MenuList        = new List <string>()
                {
                    "View all users", "Read messages", "Send message", "Read all messages", "Edit a message", "Delete a massage", "Set a new admin", "Update a user", "Delete a user", "Logout"
                };
                PrintsForMenuScreen l = new PrintsForMenuScreen(MenuList);
                MenuChoice = l.ArrowsForFirstScreen(MenuList);

                switch (MenuChoice)
                {
                case 1:
                    _users = _listOfAllUsers.GetAllUsers();
                    PrintsForMenuScreen k = new PrintsForMenuScreen(_users);
                    k.ArrowsForFirstScreen(_users);
                    break;

                case 2:
                    MessageManager mes = new MessageManager();
                    MyMessageList = mes.FindMessagesByUserId(StaticProperties.LoggedUserId).ToList();
                    if (MyMessageList.Count() == 0)
                    {
                        MessageBox.Show("You dont have any messages");
                        Console.WriteLine("You dont have any messages");
                    }
                    else
                    {
                        PrintsForMenuScreen z = new PrintsForMenuScreen(MyMessageList);
                        z.ArrowsForFirstScreen(MyMessageList);
                    }
                    break;

                case 3:
                    Console.Clear();
                    PrintLogo.MessagemyWord();
                    Console.Clear();
                    UserManager         Receiveuser = new UserManager();
                    List <User>         listofusers = new List <User>(Receiveuser.GetAllUsers());
                    PrintsForMenuScreen m           = new PrintsForMenuScreen(listofusers);
                    int ReceiverId = m.ArrowsForFirstScreen(listofusers);
                    Console.WriteLine("Type your message and press enter");
                    string         text    = Console.ReadLine();
                    MessageManager message = new MessageManager();
                    message.MessageToDb(listofusers[ReceiverId - 1].Id, text, StaticProperties.LoggedUserId);
                    MessageFileLogger log = new MessageFileLogger();
                    log.LogAMessage(StaticProperties.LoggedUserName, listofusers[ReceiverId - 1].UserName, DateTime.Now, text);
                    break;

                case 4:
                    //read all messsages
                    Console.Clear();
                    PrintLogo.MessagemyWord();
                    Console.Clear();
                    MessageManager ReadAll        = new MessageManager();
                    List <Message> listofmessages = new List <Message>();
                    listofmessages = ReadAll.GetAllMessages();
                    PrintsForMenuScreen AllMessages = new PrintsForMenuScreen(listofmessages);
                    AllMessages.ArrowsForFirstScreen(listofmessages);
                    break;

                case 5:
                    //Edit a message
                    MessageManager      ForEdit            = new MessageManager();
                    List <Message>      AllMessagesInaList = ForEdit.GetAllMessages();
                    PrintsForMenuScreen ChooseAMessage     = new PrintsForMenuScreen(AllMessagesInaList);
                    int MessageIDForTextChange             = ChooseAMessage.ArrowsForFirstScreen(AllMessagesInaList);
                    ForEdit.EditAMessageByMessageId(AllMessagesInaList[MessageIDForTextChange - 1].Id);
                    break;

                case 6:
                    //Delete a massage
                    MessageManager      ForDelete          = new MessageManager();
                    List <Message>      AllMessagesInAList = ForDelete.GetAllMessages();
                    PrintsForMenuScreen ChooseaMessage     = new PrintsForMenuScreen(AllMessagesInAList);
                    int MessageIDForDelete = ChooseaMessage.ArrowsForFirstScreen(AllMessagesInAList);
                    ForDelete.DeleteAMessageByMessageId(AllMessagesInAList[MessageIDForDelete - 1].Id);
                    break;

                case 7:
                    //Set Level of Access
                    UserManager         userManager     = new UserManager();
                    List <User>         AllUsers        = userManager.GetAllUsers();
                    PrintsForMenuScreen ChooseAUSer     = new PrintsForMenuScreen(AllUsers);
                    int           UserIDForAccessChange = ChooseAUSer.ArrowsForFirstScreen(AllUsers);
                    List <string> AccessLevels          = new List <string>()
                    {
                        "0.SimpleUser Access", "1.Lvl 1 admin(Can view all messages)", "2.Lvl 2 admin(Can view and edit all messages)", "3.Lvl 3 admin(Can view , edit and delete all messages) ", "4"
                    };
                    PrintsForMenuScreen ChooseAnAccessLvl = new PrintsForMenuScreen(AllUsers);
                    int AccessLvLForAccChange             = ChooseAnAccessLvl.ArrowsForFirstScreen(AccessLevels);
                    _users = _listOfAllUsers.GetAllUsers();
                    userManager.UpdateAUserLevelOfAccessByUserId(_users[UserIDForAccessChange - 1].Id, AccessLvLForAccChange - 1);
                    break;

                case 8:
                    //Update a user
                    PrintsForMenuScreen x           = new PrintsForMenuScreen(_users);
                    int         UserChoiceForUpdate = x.ArrowsForFirstScreen(_users);
                    UserManager forupd = new UserManager();
                    break;

                case 9:
                    //Delete a user
                    _users = _listOfAllUsers.GetAllUsers();
                    PrintsForMenuScreen o           = new PrintsForMenuScreen(_users);
                    int         UserChoiceForDelete = o.ArrowsForFirstScreen(_users);
                    UserManager fordel = new UserManager();
                    if (StaticProperties.LoggedUserName == _users[UserChoiceForDelete - 1].UserName)
                    {
                        MessageBox.Show("Vre xazouli pas na diagrapseis ton eauto sou");
                    }
                    else
                    {
                        fordel.DeleteAUserByUserId(_users[UserChoiceForDelete - 1].Id);
                    }
                    break;
                }
            }
        }