Esempio n. 1
0
        private static void AdminOperations()
        {
            PrintAdminMenu();
            int choice = int.Parse(Console.ReadLine());

            switch (choice)
            {
            case 0:
                Environment.Exit(0);
                break;

            case 1:
                Console.WriteLine("Въведете id на потребител за смяна на ролята: ");
                int userId = int.Parse(Console.ReadLine());
                Console.WriteLine("Моля въведете новата роля на потребителя: ");
                string role = Console.ReadLine();
                UserData.AssignUserRole(userId, role);
                break;

            case 2:
                Console.WriteLine("Въведете име на потребител за смяна на датата на активност: ");
                string usernameToChangeActiveDate = Console.ReadLine();
                Console.WriteLine("Въведете дата на активност във формат \"дд.мм.гггг\": ");
                string   inputedDate = Console.ReadLine();
                string   dateFormat  = "dd.MM.yyyy";
                DateTime аctiveToDate;
                if (DateTime.TryParseExact(inputedDate, dateFormat, null, DateTimeStyles.None, out аctiveToDate))
                {
                    UserData.SetUserActiveTo(usernameToChangeActiveDate, аctiveToDate);
                }
                else
                {
                    Console.WriteLine("Неправилен формат!");
                }
                break;

            case 3:
                Console.WriteLine(UserData.GetAllUsersAsText());
                break;

            case 4:
                Console.WriteLine(Logger.GetLog());
                break;

            case 5:
                Console.WriteLine("Въведете филтър");
                string filter = Console.ReadLine();
                Console.WriteLine(
                    GetSessionActivitiesAsString(Logger.GetCurrentSessionActivities(filter))
                    );
                break;
            }
        }