public Product Create(CreateProductCommand command)
        {
            var product = new Product(command.Title, command.Description, command.Price, command.QuantityOnHand, command.CategoryId);
            product.Register();
            _repository.Create(product);

            if (Commit())
                return product;

            return null;
        }
示例#2
0
        public Task<HttpResponseMessage> Post([FromBody]dynamic body)
        {
            var command = new CreateProductCommand(
                title: (string)body.title,
                category: (int)body.category,
                description: (string)body.description,
                price: (decimal)body.price,
                quantityOnHand: (int)body.quantityOnHand
            );

            var product = _service.Create(command);
            return CreateResponse(HttpStatusCode.Created, product);
        }