public void Handle(AlterProduct message)
        {
            var product = repository.GetById<Products.Domain.Product>(message.Id);

            int committedVersion = message.OriginalVersion;

            if (!String.Equals(product.Name, message.NewTitle, StringComparison.OrdinalIgnoreCase))
            {
                product.ChangeName(message.NewTitle, committedVersion++);
            }

            if (!String.Equals(product.Description, message.NewDescription, StringComparison.OrdinalIgnoreCase))
            {
                product.ChangeDescription(message.NewDescription, committedVersion++);
            }

            if (message.NewPrice != product.Price)
            {
                product.ChangePrice(message.NewPrice, committedVersion);
            }

            repository.Save(product);
        }
        public IHttpActionResult Put(Guid id, AlterProductCommand cmd)
        {
            // TODO: is this to be handled here or in the Aggregate?
            if (string.IsNullOrWhiteSpace(cmd.Name))
            {
                var response = new HttpResponseMessage(HttpStatusCode.Forbidden)
                {
                    Content = new StringContent("code must be supplied in the body"),
                    ReasonPhrase = "Missing product code"
                };
                throw new HttpResponseException(response);
            }

            try
            {
                var command = new AlterProduct(id, cmd.Version, cmd.Name, cmd.Description, cmd.Price);
                handler.Handle(command);

                return Ok(command);
            }
            catch (AggregateNotFoundException)
            {
                return NotFound();
            }
            catch (AggregateDeletedException)
            {
                return Conflict();
            }
        }