public async Task <NoContentResult> SetTag(string name, [FromBody] SetTagDto setTagDto) { var command = SetTagCommand.Create(name, setTagDto); await _mediator.Send(command); return(NoContent()); }
public static SetTagCommand Create(string currentName, SetTagDto dto) { if (currentName == null) { throw new ArgumentNullException(nameof(currentName)); } if (dto.Name == null) { throw new ArgumentNullException(nameof(dto.Name)); } if (dto.Children == null) { throw new ArgumentNullException(nameof(dto.Children)); } if (dto.Parents == null) { throw new ArgumentNullException(nameof(dto.Parents)); } if (dto.Children.Intersect(dto.Parents).Any()) { throw new ArgumentException($"An item appears in both {nameof(dto.Children)} and {nameof(dto.Parents)}."); } return(new SetTagCommand(currentName, dto.Name, dto.Description, dto.Children.ToList().AsReadOnly(), dto.Parents.ToList().AsReadOnly())); }