Exemplo n.º 1
0
 public void AllListSelectorToEdit()
 {
     PageIndex = 1;
     Console.WriteLine("Choose a message to edit.");
     Thread.Sleep(1500);
     MenuRegulator.ApplicationMenu(AllMessageListSting(), ActionsForEditMessageList());
 }
Exemplo n.º 2
0
        public void EditMessageControler()
        {
            int partToEdit = MenuRegulator.optionChoose;

            if (partToEdit == 0)
            {
                Console.WriteLine("Type a new title.");
                string userInput = ReadUserInput();
                if (userInput != CancelOperation)
                {
                    MessageMarked.Title = userInput;
                    UnitOfWork.Complete();
                    Console.WriteLine("Message edited.");
                    Thread.Sleep(1500);
                }
            }

            if (partToEdit == 1)
            {
                Console.WriteLine("Type a new message.");
                string userInput = ReadUserInput();
                if (userInput != CancelOperation)
                {
                    MessageMarked.ActualMessage = userInput;
                    UnitOfWork.Complete();
                    Console.WriteLine("Message edited.");
                    Thread.Sleep(1500);
                }
            }
            MenuRegulator.ApplicationMenu(Menu.MainMenuSignedIn(UserRepository.UserInCharge), ActionsForMainMenuSignIn(UserRepository.UserInCharge));
        }
Exemplo n.º 3
0
        ///////////////////////////////////////////////////////////////////////// User Controlers.

        public void SignUpControler()
        {
            Console.WriteLine("Type your username");
            string userName = ReadUserInput();

            do
            {
                if (CheckIfUserNameExist(userName) == true && userName != CancelOperation)
                {
                    Console.WriteLine("This user name already exists, choose another one.");
                    userName = ReadUserInput();
                }
            } while (CheckIfUserNameExist(userName) == true && userName != CancelOperation);
            if (userName != CancelOperation)
            {
                Console.WriteLine("Type your password");
                string userPassword = ReadUserInput();
                if (userPassword != CancelOperation)
                {
                    string salt = CreateSalt();
                    userPassword = userPassword + salt;
                    userPassword = PasswordToHash(userPassword);
                    SingUp(userName, userPassword, salt);
                }
            }
            MenuRegulator.ApplicationMenu(Menu.StartingMenu(), ActionsForStartingMenu());
        }
Exemplo n.º 4
0
        /////////////////////////////////////////////////////////////////////////// Message menu caller.


        public void CallMessageUserToSend()
        {
            PageIndex = 1;
            Console.WriteLine("Choose a user to send message to.");
            Thread.Sleep(1500);
            MenuRegulator.ApplicationMenu(UserNamesToListOfStrings(), ActionsForChoosingUser());
        }
Exemplo n.º 5
0
        public void SignInControler()
        {
            Console.WriteLine("Type your username.");
            string userName = ReadUserInput();

            do
            {
                if (CheckIfUserNameExist(userName) == false && userName != CancelOperation)
                {
                    Console.WriteLine("This user name does not exist, choose another one.");
                    userName = ReadUserInput();
                }
            } while (CheckIfUserNameExist(userName) == false && userName != CancelOperation);
            if (userName != CancelOperation)
            {
                Console.WriteLine($"Type your password user {userName}.");
                string password = ReadUserInput();
                if (password != CancelOperation)
                {
                    string salt = GetSalt(userName);
                    password = password + salt;
                    password = PasswordToHash(password);
                    if (SignIn(userName, password) == true)
                    {
                        Console.WriteLine("you are singed in");

                        UserInCharge = GetUserByUserName(userName);
                        Thread.Sleep(1500);
                    }
                }
            }
            MenuRegulator.ApplicationMenu(Menu.MainMenuSignedIn(UserInCharge), UnitOfWork.Messages.ActionsForMainMenuSignIn(UserInCharge));
        }
Exemplo n.º 6
0
        public void RemoveUserControler()
        {
            var user = GetSelectedUser();

            RemoveUser(user);
            MenuRegulator.ApplicationMenu(Menu.MainMenuSignedIn(UserInCharge), UnitOfWork.Messages.ActionsForMainMenuSignIn(UserInCharge));
        }
Exemplo n.º 7
0
 public void MessageDeleteSelector()
 {
     PageIndex = 1;
     Console.WriteLine("Choose which message to delete.");
     Thread.Sleep(1500);
     MenuRegulator.ApplicationMenu(AllMessageListSting(), ActionsForDeleteMessageSelector());
 }
Exemplo n.º 8
0
        private List <string> GetAllMessageListIndexed(int pageIndex, int pageSize)
        {
            int counter          = 0;
            var numberOfMessages = GetAll().Count();

            var messagesList = GetAll().Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList();

            var messageStrings = new List <string>();

            if (pageIndex > 1)
            {
                messageStrings.Add("Previous eight");
            }
            foreach (var message in messagesList)
            {
                messageStrings.Add($"Message from [{message.SenterId.Name.ToString()}]. Title [{message.Title.ToString()}].");
                counter++;
            }
            if ((numberOfMessages % (pageIndex * pageSize) > 0 && numberOfMessages % (pageIndex * pageSize) != numberOfMessages) || (numberOfMessages % (pageIndex * pageSize) == 0 && numberOfMessages > (pageIndex * pageSize)))
            {
                messageStrings.Add("Next eight");
            }
            if (counter > 0)
            {
                return(messageStrings);
            }
            else
            {
                Console.WriteLine("There are no messages.");
                Thread.Sleep(1500);
                MenuRegulator.ApplicationMenu(Menu.MainMenuSignedIn(UserRepository.UserInCharge), ActionsForMainMenuSignIn(UserRepository.UserInCharge));

                return(new List <string>());
            }
        }
Exemplo n.º 9
0
 public void ReadOutboxListSelector()
 {
     PageIndex = 1;
     Console.WriteLine("Choose a message to read.");
     Thread.Sleep(1500);
     MenuRegulator.ApplicationMenu(OutboxMessageStringList(), ActionsForOutboxMessageList());
 }
Exemplo n.º 10
0
 public void MessagePartSelector()
 {
     MessageMarked = GetSelectedMessage(GetAll().Skip((PageIndex - 1) * PagesSize).Take(PagesSize).ToList());
     Console.WriteLine("Choose which part to edit.");
     Thread.Sleep(1500);
     MenuRegulator.ApplicationMenu(MessagePartListString(), ActionForEditMessagePartSelector());
 }
Exemplo n.º 11
0
 public void ChangeAccessLevelControler()
 {
     UserMarked.AccessLevel = MenuRegulator.optionChoose + 1;
     UnitOfWork.Complete();
     Console.WriteLine("User access level changed");
     Thread.Sleep(1500);
     MenuRegulator.ApplicationMenu(Menu.MainMenuSignedIn(UserInCharge), UnitOfWork.Messages.ActionsForMainMenuSignIn(UserInCharge));
 }
Exemplo n.º 12
0
        //////////////////////////////////////////////////////////////////////// Action user menu support.



        public void ToChooseUserMenuToChangeAccessLevel()
        {
            MessageRepository.PageIndex = 1;
            Console.WriteLine();
            Console.WriteLine("Choose a user to change its access level");
            Thread.Sleep(1500);
            MenuRegulator.ApplicationMenu(UnitOfWork.Messages.UserNamesToListOfStrings(), ActionsForChoosingUserToChangeAccessLevel());
        }
Exemplo n.º 13
0
        public void DeleteMessageControler()
        {
            var message = GetSelectedMessage(GetAll().Skip((PageIndex - 1) * PagesSize).Take(PagesSize).ToList());

            UnitOfWork.Messages.Remove(message);
            UnitOfWork.Complete();
            Console.WriteLine("Message deleted.");
            Thread.Sleep(1500);

            MenuRegulator.ApplicationMenu(Menu.MainMenuSignedIn(UserRepository.UserInCharge), ActionsForMainMenuSignIn(UserRepository.UserInCharge));
        }
Exemplo n.º 14
0
        public void ReadOutboxMessageControler()
        {
            var message = GetSelectedMessage(Find(Message1 => Message1.SenterId.Id == UserRepository.UserInCharge.Id).Skip((PageIndex - 1) * PagesSize).Take(PagesSize).ToList());

            Console.WriteLine($"Date: {message.MessageDate}, From: {message.SenterId.Name}");
            Console.WriteLine($"Title: {message.Title} ");
            Console.WriteLine($"Message: {message.ActualMessage}");
            Console.WriteLine();
            Console.WriteLine("Press any key to go back to menu");
            Console.ReadKey();
            MenuRegulator.ApplicationMenu(Menu.ReadMessageMenu(), ActionsForReadMessageMenu());
        }
Exemplo n.º 15
0
        public void ReadAllMessageControler()
        {
            var message = GetSelectedMessage(GetAll().Skip((PageIndex - 1) * PagesSize).Take(PagesSize).ToList());

            Console.WriteLine($"Date: {message.MessageDate}, From: {message.SenterId.Name}");
            Console.WriteLine($"Title: {message.Title} ");
            Console.WriteLine($"Message: {message.ActualMessage}");
            Console.WriteLine();
            Console.WriteLine("Press any key to go back to menu");
            Console.ReadKey();

            MenuRegulator.ApplicationMenu(Menu.MainMenuSignedIn(UserRepository.UserInCharge), ActionsForMainMenuSignIn(UserRepository.UserInCharge));
        }
Exemplo n.º 16
0
        private List <string> GetOutboxMessageListIndexed(int pageIndex, int pageSize)
        {
            int           counter        = 0;
            List <string> messageStrings = new List <string>();

            var numberOfMessages = UnitOfWork.Messages.Find(message => message.SenterId.Id == UserRepository.UserInCharge.Id).Count();

            if (pageIndex > 1)
            {
                messageStrings.Add("Previous eight");
            }
            var messageListInbox = UnitOfWork.Messages.Find(message => message.SenterId.Id == UserRepository.UserInCharge.Id).Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList();

            foreach (var message in messageListInbox)
            {
                if (message.IsRead == true)
                {
                    messageStrings.Add($"Message to [{message.ReceiverId.Name.ToString()}]. Title [{message.Title.ToString()}].");
                    counter++;
                }
                else
                {
                    messageStrings.Add($"[Unread!] Message to [{message.ReceiverId.Name.ToString()}]. Title [{message.Title.ToString()}].");
                    counter++;
                }
            }
            if (counter > 0)
            {
                if ((numberOfMessages % (pageIndex * pageSize) > 0 && numberOfMessages % (pageIndex * pageSize) != numberOfMessages) || (numberOfMessages % (pageIndex * pageSize) == 0 && numberOfMessages > (pageIndex * pageSize)))
                {
                    messageStrings.Add("Next eight");
                }
                return(messageStrings);
            }
            else
            {
                if (counter == 0)
                {
                    Console.WriteLine("There are no messages");
                    Thread.Sleep(1500);
                    MenuRegulator.ApplicationMenu(Menu.ReadMessageMenu(), ActionsForReadMessageMenu());
                }

                return(new List <string>());
            }
        }
Exemplo n.º 17
0
        //////////////////////////////////////////////////////////////////////////// Message controlers.


        public void CreateMessageControler()
        {
            int idReceiver = UnitOfWork.Users.GetSelectedUser().Id;
            int idSender   = UserRepository.UserInCharge.Id;

            Console.WriteLine("Please type a title for your Message.");
            string title = ReadUserInput();

            if (title != CancelOperation)
            {
                Console.WriteLine("Now type your message");
                string message = ReadUserInput();
                if (message != CancelOperation)
                {
                    CreateMessage(title, message, idSender, idReceiver);
                    Console.WriteLine("Message created");
                    Thread.Sleep(1500);
                }
            }
            MenuRegulator.ApplicationMenu(Menu.MainMenuSignedIn(UserRepository.UserInCharge), ActionsForMainMenuSignIn(UserRepository.UserInCharge));
        }
Exemplo n.º 18
0
        public void ChooseWhichAccessLevel()
        {
            UserMarked = GetSelectedUser();

            MenuRegulator.ApplicationMenu(Menu.AccessLevelStringList(), ActionsForChangingAccessLevel());
        }
Exemplo n.º 19
0
 private void BrowseUsersForAccessLevelPlus()
 {
     MessageRepository.PageIndex++;
     MenuRegulator.ApplicationMenu(UnitOfWork.Messages.UserNamesToListOfStrings(), ActionsForChoosingUserToChangeAccessLevel());
 }
Exemplo n.º 20
0
 private void BrowseDeleteMessagePlus()
 {
     PageIndex++;
     MenuRegulator.ApplicationMenu(GetAllMessageListIndexed(PageIndex, PagesSize), ActionsForDeleteMessageSelector());
 }
Exemplo n.º 21
0
 private void BrowseEditMessagePlus()
 {
     PageIndex++;
     MenuRegulator.ApplicationMenu(GetAllMessageListIndexed(PageIndex, PagesSize), ActionsForEditMessageList());
 }
Exemplo n.º 22
0
 private void BrowseAllMessageMinus()
 {
     PageIndex--;
     MenuRegulator.ApplicationMenu(GetAllMessageListIndexed(PageIndex, PagesSize), ActionsForReadAllMessageList());
 }
Exemplo n.º 23
0
 private void BrowseOutboxPlus()
 {
     PageIndex++;
     MenuRegulator.ApplicationMenu(GetOutboxMessageListIndexed(PageIndex, PagesSize), ActionsForOutboxMessageList());
 }
Exemplo n.º 24
0
 private void BrowseUsersPlus()
 {
     PageIndex++;
     MenuRegulator.ApplicationMenu(UnitOfWork.Users.GetUserListIndexed(PageIndex, PagesSize), ActionsForChoosingUser());
 }
Exemplo n.º 25
0
 private void BrowseUsersForRemovingPlus()
 {
     MessageRepository.PageIndex++;
     MenuRegulator.ApplicationMenu(UnitOfWork.Messages.UserNamesToListOfStrings(), ActionsForChoosingUserToRemove());
 }
Exemplo n.º 26
0
 public void ToChooseUserToRemove()
 {
     MessageRepository.PageIndex = 1;
     MenuRegulator.ApplicationMenu(UnitOfWork.Messages.UserNamesToListOfStrings(), ActionsForChoosingUserToRemove());
 }
Exemplo n.º 27
0
 public void ReadMessageMenu()
 {
     MenuRegulator.ApplicationMenu(Menu.ReadMessageMenu(), ActionsForReadMessageMenu());
 }