Exemplo n.º 1
0
        public async Task <IActionResult> CreateAsync([FromBody] InToolDTO toolDTO)
        {
            var tool = ToolMapper.Map(toolDTO);

            tool = _repositoryManager.ToolRepository.Create(tool);

            await _repositoryManager.SaveAsync();

            return(Ok(ToolMapper.Map(tool)));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> UpdateAsync([FromRoute] int id,
                                                      [FromBody] InToolDTO toolDTO)
        {
            var tool = await _repositoryManager.ToolRepository.GetAsync(id);

            if (tool == null)
            {
                return(NotFound());
            }

            tool.Update(toolDTO);

            _repositoryManager.ToolRepository.Update(tool);

            await _repositoryManager.SaveAsync();

            return(Ok(ToolMapper.Map(tool)));
        }