public static void SetNullIdOrThrowOnInconsistentIds(string id, CreateOrMergePatchOrDeleteDocumentTypeDto value) { var idObj = id; if (value.DocumentTypeId == null) { value.DocumentTypeId = idObj; } else if (!((ICreateOrMergePatchOrDeleteDocumentType)value).DocumentTypeId.Equals(idObj)) { throw DomainError.Named("inconsistentId", "Argument Id {0} NOT equals body Id {1}", id, value.DocumentTypeId); } }
public void Put(string id, [FromBody] CreateOrMergePatchOrDeleteDocumentTypeDto value) { try { // /////////////////////////////// if (value.Version != default(long)) { value.CommandType = CommandType.MergePatch; DocumentTypesControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value); _documentTypeApplicationService.When(value as IMergePatchDocumentType); return; } // /////////////////////////////// DocumentTypesControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value); _documentTypeApplicationService.When(value as ICreateDocumentType); } catch (Exception ex) { var response = HttpServiceExceptionUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }