Ejemplo n.º 1
0
        public async Task <IActionResult> CreateTool(ToolForCreationDto tool)
        {
            for (int i = 0; i < tool.Tags.Length; i++)
            {
                tool.Tags[i] = tool.Tags[i].ToLower();
            }
            var toolEntity = _mapper.Map <Tool>(tool);

            _repository.CreateTool(toolEntity);
            await _unitOfWork.SaveChanges();

            var toolToReturn = _mapper.Map <ToolDto>(toolEntity);

            return(CreatedAtRoute("ToolById", new { id = toolToReturn.Id }, toolToReturn));
        }