Example #1
0
        public async Task AddSkillAsync(int programmerId, SkillModel skill)
        {
            if (skill.IsSkillExist(context, programmerId))
            {
                throw new UnuniqueException("this skill is already exists");
            }
            if (skill.IsSkillModelNotValid())
            {
                throw new ModelException("uncorrect model", HttpStatusCode.BadRequest);
            }

            skill.ProgrammerId = programmerId;
            await context.SkillRepository.AddAsync(mapper.Map <Skill>(skill));

            context.Save();
        }
Example #2
0
        public async Task EditSkillAsync(int programmerId, SkillModel skill)
        {
            if (!skill.IsSkillExist(context, programmerId))
            {
                throw new UnuniqueException("you don`t have this skill");
            }
            if (skill.IsSkillModelNotValid())
            {
                throw new ModelException("uncorrect model", HttpStatusCode.BadRequest);
            }

            skill.ProgrammerId = programmerId;
            var sk = await context.SkillRepository.GetByIdAsync(skill.Id);

            context.SkillRepository.Update(mapper.Map(skill, sk));

            await context.SaveAsync();
        }