Esempio n. 1
0
        public async Task <SkillDto> CreateSkillAsync(CreateSkillDto input)
        {
            var skill = ObjectMapper.Map <Skill>(input);

            skill = await _skillRepo.InsertAsync(skill);

            await CurrentUnitOfWork.SaveChangesAsync();

            return(ObjectMapper.Map <SkillDto>(skill));
        }
Esempio n. 2
0
        public async Task <ApiResponse <object> > Create(CreateSkillDto request)
        {
            var command = new CreateSkillCommand
            {
                Name   = request.Name,
                Damage = request.Damage
            };
            await _operationMediator.HandleAsync(command);

            var location = Url.Link(GetByIdRouteName, new { id = command.GeneratedId });

            return(ApiResponse.Created(location, command.GeneratedId));
        }
Esempio n. 3
0
        public async Task <SkillDto> CreateNewSkill(CreateSkillDto createSkillDto)
        {
            var employee = await _employeeRepository.GetById(createSkillDto.EmployeeId);

            if (employee == null)
            {
                return(null);
            }
            var newSkill = _createSkillMapper.Map(createSkillDto);

            newSkill.Employee = employee;
            newSkill          = await _skillRepository.Insert(newSkill);

            return(_skillMapper.Map(newSkill));
        }
Esempio n. 4
0
        public async Task <IActionResult> CreateNewSkill([FromBody] CreateSkillDto createSkillDto)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var newSkillDto = await _skillService.CreateNewSkill(createSkillDto);

            if (newSkillDto == null)
            {
                return(NotFound());
            }
            return(Ok(newSkillDto));
        }
Esempio n. 5
0
        public async Task <IActionResult> Create(CreateSkillDto input)
        {
            var newSkill = await _skillAppService.CreateSkillAsync(input);

            return(CreatedAtRoute("GetSkill", new { id = newSkill.Id }, newSkill));
        }