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)); }
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)); }
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)); }
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)); }
public async Task <IActionResult> Create(CreateSkillDto input) { var newSkill = await _skillAppService.CreateSkillAsync(input); return(CreatedAtRoute("GetSkill", new { id = newSkill.Id }, newSkill)); }