Ejemplo n.º 1
0
        public void Execute(int command)
        {
            switch (command)
            {
            case 1:
                DisplayRegForm();
                bool isReg = UserService.Registrate(new User
                {
                    FirstName = userData.FirstName,
                    LastName  = userData.LastName,
                    Age       = userData.Age,
                    Email     = userData.Email,
                    Login     = userData.Login,
                    Password  = userData.Password
                });
                if (isReg == true)
                {
                    Console.WriteLine("Вы зарегались");
                }
                else
                {
                    Console.WriteLine("Вы не зарегались");
                }
                break;

            case 2:
                DisplayLoginForm();
                int idAuthUser = UserService.Authorizate(userData.Login, userData.Password);
                UserSession.Id = idAuthUser;
                if (idAuthUser >= 0)
                {
                    Console.WriteLine("Вы вошли в систему");
                    UserSession.Id = idAuthUser;
                }
                else
                {
                    Console.WriteLine("Неверный пароль или логин");
                }
                break;
            }
            if (UserSession.Id >= 0)
            {
                switch (command)
                {
                case 3:

                    if (UserSession.Id >= 0)
                    {
                        DisplayCourseCreatingForm();
                        CourseDTO.Id = CourseService.CreateCourse(
                            Course.Name,
                            Course.Description
                            );
                        if (CourseDTO.Id >= 0)
                        {
                            Console.WriteLine("Курс создан");
                        }
                        else
                        {
                            Console.WriteLine("Курс не создан");
                        }
                    }
                    break;

                case 4:
                    if (UserSession.Id >= 0)
                    {
                        PrintMaterailsCommands();
                        int numberOfMaterial = SelectCommand();
                        if (numberOfMaterial == 1)
                        {
                            DisplayArticleCreatingForm();
                            ArticleMaterial.Id = MaterialService.CreateArticleMaterial(new ArticleMaterial
                            {
                                Name      = ArticleMaterial.Name,
                                Link      = ArticleMaterial.Link,
                                Published = ArticleMaterial.Published
                            });

                            CourseService.AddMaterialToCourse(CourseDTO.Id, ArticleMaterial.Id);
                        }
                        if (numberOfMaterial == 2)
                        {
                            DisplayVideoCreatingForm();
                            MaterialService.CreateVideoMaterial(new VideoMaterial
                            {
                                Name     = VideoMaterial.Name,
                                Duration = VideoMaterial.Duration,
                                Quality  = VideoMaterial.Quality
                            });
                        }
                        if (numberOfMaterial == 3)
                        {
                            DisplayBookCreatingForm();
                            MaterialService.CreateBookMaterial(new BookMaterial
                            {
                                Name   = BookMaterial.Name,
                                Author = BookMaterial.Author,
                                Format = BookMaterial.Format,
                                Issued = BookMaterial.Issued,
                                Page   = BookMaterial.Page
                            });
                        }
                    }
                    break;

                case 5:
                    foreach (var m in MaterialService.GetAllMaterials())
                    {
                        PrintMaterial(m);
                    }
                    break;

                case 6:
                    DisplaySkillCreatingForm();
                    SkillService.CreateSkill("Skill1");
                    break;

                case 7:
                    //DisplaySkillCreatingForm();
                    CourseService.GetCourseWithProgress(UserSession.Id, CourseDTO.Id);
                    break;
                }
            }
        }