Ejemplo n.º 1
0
        // POST: api/Skills
        public GenericResponse <string> PostSkill(SkillModel skill)
        {
            //TODO: THIS VALIDATION CAN BE EXTRACTED INTO A VALIDATION METHOD FOR REUSABILITY
            if (!ModelState.IsValid)
            {
                return(new GenericResponse <string>
                {
                    StatusCode = 400,
                    Message = "BAD REQUEST"
                });
            }

            if (service.AddSkill(skill) == 1)
            {
                return(new GenericResponse <string>
                {
                    StatusCode = 200,
                    Message = "NO CONTENT"
                });
            }

            return(new GenericResponse <string>
            {
                StatusCode = 500,
                Message = "SERVER ERROR"
            });
        }
Ejemplo n.º 2
0
        public async Task AddSkill_ToNonExistingResume_ReturnsFalse()
        {
            var context = new JobFinderDbContext(new DbContextOptionsBuilder <JobFinderDbContext>()
                                                 .UseInMemoryDatabase(Guid.NewGuid().ToString())
                                                 .Options);

            var model = new Resume()
            {
                JobSeeker = new JobSeeker()
                {
                    FirstName = "JobSeekerName1",
                    LastName  = "JobSeekerName2",
                    User      = new User()
                    {
                        UserName = "******"
                    }
                }
            };

            var serviceModel = new SkillServiceModel();

            var skillService = new SkillService(new EfRepository <Resume>(context),
                                                new EfRepository <Skill>(context));

            var result = await skillService.AddSkill(model.Id, serviceModel);

            Assert.False(result);
        }
Ejemplo n.º 3
0
        public async Task AddSkill_WithValidData_ToExistingResume_WorksCorrectly()
        {
            var context = new JobFinderDbContext(new DbContextOptionsBuilder <JobFinderDbContext>()
                                                 .UseInMemoryDatabase(Guid.NewGuid().ToString())
                                                 .Options);

            var model = new Resume()
            {
                JobSeeker = new JobSeeker()
                {
                    FirstName = "JobSeekerName1",
                    LastName  = "JobSeekerName2",
                    User      = new User()
                    {
                        UserName = "******"
                    }
                }
            };

            await context.AddAsync(model);

            context.SaveChanges();

            var serviceModel = new SkillServiceModel()
            {
                Name = "SkillName1"
            };

            var skillService = new SkillService(new EfRepository <Resume>(context),
                                                new EfRepository <Skill>(context));

            var result = await skillService.AddSkill(model.Id, serviceModel);

            Assert.True(result);
        }
Ejemplo n.º 4
0
    public void OnClickSelectOption(string option)
    {
        Toggle();

        var heroName = Heroes[CurrentHeroIndex];
        var hero     = HeroService.LoadHero(heroName);

        var skillName = ArrangedSkillKnowledges[SelectedSkillIndex].name;

        try
        {
            SkillService.AddSkill(hero, skillName, option);
        }
        catch (BusinessException.BusinessException e)
        {
            AddSkillError.transform.localScale = new Vector3(1, 1, 1);
            ErrorMessage      = GameObject.FindGameObjectWithTag("ErrorMessage").GetComponent <Text>();
            ErrorMessage.text = e.Message;
        }
    }
Ejemplo n.º 5
0
 public async Task AddSkill([FromBody] SkillData data)
 {
     await _service.AddSkill(data);
 }