Esempio n. 1
0
        public BaseResponse <SkillOutputDto> Update(Guid id, SkillInputDto skillInputDto)
        {
            var skill = First(x => x.EntityStatus == EntityStatus.Activated && x.Id == id);

            skill.Name = skillInputDto.Name;
            var isSaved = Update(skill);

            if (!isSaved)
            {
                throw new InternalServerErrorException(string.Format(Error.CreateError, skillInputDto.Name));
            }

            return(new SuccessResponse <SkillOutputDto>(Mapper.Map <SkillOutputDto>(skill)));
        }
Esempio n. 2
0
        public BaseResponse <SkillOutputDto> Create(SkillInputDto skillInputDto)
        {
            if (Contains(x => x.EntityStatus == EntityStatus.Activated && x.Name.Equals(skillInputDto.Name, StringComparison.InvariantCultureIgnoreCase)))
            {
                throw new BadRequestException($"Skill {skillInputDto.Name} is already existed");
            }
            var skill = Create(Mapper.Map <Skill>(skillInputDto), out var isSaved);

            if (!isSaved)
            {
                throw new InternalServerErrorException(string.Format(Error.CreateError, skillInputDto.Name));
            }

            return(new SuccessResponse <SkillOutputDto>(Mapper.Map <SkillOutputDto>(skill)));
        }
 public BaseResponse <SkillOutputDto> Update(Guid id, [FromBody] SkillInputDto skill)
 {
     return(_skillService.Update(id, skill));
 }
 public BaseResponse <SkillOutputDto> Create([FromBody] SkillInputDto skill)
 {
     return(_skillService.Create(skill));
 }