public static void SetNullIdOrThrowOnInconsistentIds(string id, CreateOrMergePatchOrDeleteAttributeDto value)
        {
            var idObj = id;

            if (value.AttributeId == null)
            {
                value.AttributeId = idObj;
            }
            else if (!((ICreateOrMergePatchOrDeleteAttribute)value).AttributeId.Equals(idObj))
            {
                throw DomainError.Named("inconsistentId", "Argument Id {0} NOT equals body Id {1}", id, value.AttributeId);
            }
        }
Beispiel #2
0
        public void Put(string id, [FromBody] CreateOrMergePatchOrDeleteAttributeDto value)
        {
            try {
                // ///////////////////////////////
                if (value.Version != default(long))
                {
                    value.CommandType = CommandType.MergePatch;
                    AttributesControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value);
                    _attributeApplicationService.When(value as IMergePatchAttribute);
                    return;
                }
                // ///////////////////////////////

                AttributesControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value);
                _attributeApplicationService.When(value as ICreateAttribute);
            } catch (Exception ex) { var response = AttributesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); }
        }