Esempio n. 1
0
        public static void SetNullIdOrThrowOnInconsistentIds(string id, CreateOrMergePatchOrDeleteSupplierProductDto value)
        {
            var idObj = ParseIdString(id.IsNormalized() ? id : id.Normalize());

            if (value.SupplierProductId == null)
            {
                value.SupplierProductId = idObj;
            }
            else if (!((ICreateOrMergePatchOrDeleteSupplierProduct)value).SupplierProductId.Equals(idObj))
            {
                throw DomainError.Named("inconsistentId", "Argument Id {0} NOT equals body Id {1}", id, value.SupplierProductId);
            }
        }
Esempio n. 2
0
        public void Put(string id, [FromBody] CreateOrMergePatchOrDeleteSupplierProductDto value)
        {
            try {
                // ///////////////////////////////
                if (value.Version != default(long))
                {
                    value.CommandType = CommandType.MergePatch;
                    SupplierProductsControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value);
                    _supplierProductApplicationService.When(value as IMergePatchSupplierProduct);
                    return;
                }
                // ///////////////////////////////

                SupplierProductsControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value);
                _supplierProductApplicationService.When(value as ICreateSupplierProduct);
            } catch (Exception ex) { var response = SupplierProductsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
        }