Exemplo n.º 1
0
        public async Task CreateSkillTest()
        {
            // Arrange
            var client = SetupMock_Skill();
            var config = new Mock <IConfiguration>();

            client.BaseAddress = new Uri("https://localhost:1111/");
            config.SetupGet(s => s["SkillsURL"]).Returns("https://localhost:1111/");
            var service = new SkillService(null, new NullLogger <SkillService>(), config.Object)
            {
                Client = client
            };

            // Act
            var newSkill = new SkillDTO
            {
                Id     = 9,
                XpCost = 5,
                Name   = "NEWSKILL"
            };
            var result = await service.CreateSkill(newSkill);

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(newSkill.Id, result.Id);
            Assert.AreEqual(newSkill.Name, result.Name);
            Assert.AreEqual(newSkill.XpCost, result.XpCost);
        }
Exemplo n.º 2
0
        public ActionResult Create(SkillCreate skill)
        {
            if (!ModelState.IsValid)
            {
                return(View(skill));
            }

            var userId  = Guid.Parse(User.Identity.GetUserId());
            var service = new SkillService(userId);

            service.CreateSkill(skill);
            return(RedirectToAction("Index"));
        }
Exemplo n.º 3
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;
                }
            }
        }