Esempio n. 1
0
        public HttpResponseMessage Post([FromBody] CreateSellableInventoryItemDto value)
        {
            try {
                if (value.SellableInventoryItemId == default(InventoryItemId))
                {
                    throw DomainError.Named("nullId", "Aggregate Id in cmd is null, aggregate name: {0}.", "SellableInventoryItem");
                }
                _sellableInventoryItemApplicationService.When(value as ICreateSellableInventoryItem);
                var idObj = value.SellableInventoryItemId;

                return(Request.CreateResponse <InventoryItemId>(HttpStatusCode.Created, idObj));
            } catch (Exception ex) { var response = SellableInventoryItemsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
        }
        public async Task WhenAsync(CreateSellableInventoryItemDto c)
        {
            var idObj         = SellableInventoryItemProxyUtils.ToIdString((c as ICreateSellableInventoryItem).SellableInventoryItemId);
            var uriParameters = new SellableInventoryItemUriParameters();

            uriParameters.Id = idObj;

            var req = new SellableInventoryItemPutRequest(uriParameters, (CreateSellableInventoryItemDto)c);

            var resp = await _ramlClient.SellableInventoryItem.Put(req);

            SellableInventoryItemProxyUtils.ThrowOnHttpResponseError(resp);
        }
 public void When(CreateSellableInventoryItemDto c)
 {
     WhenAsync(c).GetAwaiter().GetResult();
 }