public static void SetNullIdOrThrowOnInconsistentIds(string id, CreateOrMergePatchOrDeleteAttributeValueMvoDto value)
        {
            var idObj = ParseIdString(id.IsNormalized() ? id : id.Normalize());

            if (value.AttributeValueId == null)
            {
                value.AttributeValueId = new AttributeValueIdDtoWrapper(idObj);
            }
            else if (!((ICreateOrMergePatchOrDeleteAttributeValueMvo)value).AttributeValueId.Equals(idObj))
            {
                throw DomainError.Named("inconsistentId", "Argument Id {0} NOT equals body Id {1}", id, value.AttributeValueId);
            }
        }
Beispiel #2
0
        public void Put(string id, [FromBody] CreateOrMergePatchOrDeleteAttributeValueMvoDto value)
        {
            try {
                // ///////////////////////////////
                if (value.AttributeVersion != default(long))
                {
                    value.CommandType = CommandType.MergePatch;
                    AttributeValueMvosControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value);
                    _attributeValueMvoApplicationService.When(value as IMergePatchAttributeValueMvo);
                    return;
                }
                // ///////////////////////////////

                AttributeValueMvosControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value);
                _attributeValueMvoApplicationService.When(value as ICreateAttributeValueMvo);
            } catch (Exception ex) { var response = AttributeValueMvosControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
        }