Beispiel #1
0
        internal void Functionality()
        {
            IRepository <User> userRepository = new UserRepository(context);
            var interactionCommands           = new InteractionCommands();


            this.MenuInfo();
            while (true)
            {
                Console.WriteLine("Select a number and press enter!");
                var command = Console.ReadLine();
                if (command == "0")
                {
                    break;
                }

                switch (command)
                {
                case "1":
                    registrationService.Register();
                    break;

                case "2":
                    if (!session.IsAuthorised)
                    {
                        authorizationService.SignIn(userRepository);
                    }
                    else
                    {
                        Console.WriteLine("Already authorised");
                    }
                    break;

                case "3":
                    if (session.IsAuthorised)
                    {
                        authorizationService.SignOut();
                    }
                    else
                    {
                        Console.WriteLine("Already unauthorised");
                    }
                    break;

                case "4":
                    Console.WriteLine(session.IsAuthorised ? "Yes" : "No");
                    break;

                case "5":
                    interactionCommands.Show(userRepository);
                    break;

                case "6":
                    Console.WriteLine("Enter the email you want to delete.");
                    interactionCommands.Delete(userRepository);
                    break;

                case "7":
                    Console.Clear();
                    MenuInfo();
                    break;

                case "8":
                    materialInputService.MaterialInfoInput();
                    break;

                case "9":
                    materialService.ShowMaterials();
                    break;

                case "10":
                    courseInputService.CourseinfoInput();
                    break;

                //case "11":
                //    var courses = courseService.GetCourses();
                //    if (!courses.Any())
                //    {
                //        Console.WriteLine("no courses found");
                //    }
                //    else
                //    {
                //        foreach (var course in courses)
                //        {
                //            Console.WriteLine(course);
                //        }
                //    }
                //    break;
                case "12":
                    courseInputService.CourseInfoUpdate();
                    break;

                case "13":
                    skillInputService.SkillInfoInput();
                    break;

                case "14":
                    userInfoInputService.PrintSessionUser();
                    break;

                case "15":
                    courseInputService.StartCourse();
                    break;

                case "16":
                    if (session.IsAuthorised)
                    {
                        courseService.GetStartedCourses(session.User.Email).ForEach(c => Console.WriteLine(c));
                    }
                    else
                    {
                        Console.WriteLine("You need to authorise");
                    }
                    break;

                case "17":
                    if (session.IsAuthorised)
                    {
                        courseInputService.CompleteCourse();
                    }
                    else
                    {
                        Console.WriteLine("You need to authorise");
                    }
                    break;

                case "18":
                    if (session.IsAuthorised)
                    {
                        courseService.GetCompletedCourses(session.User.Email).ForEach(c => Console.WriteLine(c));
                    }
                    else
                    {
                        Console.WriteLine("You need to authorise");
                    }
                    break;

                default:
                    Console.WriteLine("Command not found!");
                    break;
                }
            }
        }