Пример #1
0
        public async Task <ResponseLogic> CreateAsync(SkillCreateDTO skill)
        {
            var currentSkill = await _repository.FindAsync(skill.Name);

            if (currentSkill != null)
            {
                return(ResponseLogic.SUCCESS);
            }

            var createdId = await _repository.CreateAsync(skill);

            if (createdId > 0)
            {
                return(ResponseLogic.SUCCESS);
            }
            else
            {
                return(ResponseLogic.ERROR_CREATING);
            }
        }
Пример #2
0
        public async Task <SkillDto> CreateSkillAsync(RegisterSkillRequest request)
        {
            var existingSkill = _skillRepository.GetSkillByTitle(request.Title);

            if (existingSkill != null)
            {
                throw new InsertFailedException("Skill already added in the System!");
            }

            var newSkill = new Entities.Skill
            {
                Id        = Guid.NewGuid().ToString(),
                CreatedBy = request.CreatedBy,
                Title     = request.Title
            };

            await _skillRepository.CreateAsync(newSkill);

            return(new SkillDto
            {
                Id = newSkill.Id,
                Title = newSkill.Title
            });
        }