public void Execute(CreateCategoryCommand command) { if (!command.Id.HasValue) { throw new ArgumentNullException("Id", "Category must have a id"); } if (string.IsNullOrWhiteSpace(command.Name)) { throw new ArgumentOutOfRangeException("Name", "Category must have a name"); } if (persistence.FindByName(command.Name) != null) { throw new ArgumentException(); } persistence.Create(new Category(id: command.Id.Value, name: command.Name)); }