示例#1
0
        public async Task <OutToolDTO> UpdateToolAsync(string toolName, InToolDTO inToolDto)
        {
            var tool = await _toolRepository.GetByName(toolName);

            if (tool != null)
            {
                tool.Name = inToolDto.Tool;
            }

            var updatedtool = await _toolRepository.Update(tool);

            return(new OutToolDTO()
            {
                Tool = updatedtool.Name
            });
        }
示例#2
0
        public void UpdateTool(string id, ToolForUpdateDto toolForUpdate)
        {
            // Want to try to find the owner first before updating. Throw error if the owner does not exist.
            // What if the user attempts to modify the id field for the owner? Throw error.
            var tool = GetToolById(id);

            if (tool == null)
            {
                //_logger.LogError($"Owner with id: {id}, hasn't been found in db.");
                return;
                // TODO: need to return notfound to the user
            }

//TODO validate new tool
            //_mapper.Map(owner, ownerEntity);
            tool.Name              = toolForUpdate.Name;
            tool.Description       = toolForUpdate.Description;
            tool.DailyCost         = toolForUpdate.DailyCost;
            tool.ReplacementCost   = toolForUpdate.ReplacementCost;
            tool.QuantityAvailable = toolForUpdate.QuantityAvailable;
            _toolRepository.Update(tool.ToolId, tool);
        }