public static void SetNullIdOrThrowOnInconsistentIds(string id, CreateOrMergePatchOrDeleteMovementConfirmationDto value) { var idObj = id; if (value.DocumentNumber == null) { value.DocumentNumber = idObj; } else if (!((ICreateOrMergePatchOrDeleteMovementConfirmation)value).DocumentNumber.Equals(idObj)) { throw DomainError.Named("inconsistentId", "Argument Id {0} NOT equals body Id {1}", id, value.DocumentNumber); } }
public void Put(string id, [FromBody] CreateOrMergePatchOrDeleteMovementConfirmationDto value) { try { // /////////////////////////////// if (value.Version != default(long)) { value.CommandType = CommandType.MergePatch; MovementConfirmationsControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value); _movementConfirmationApplicationService.When(value as IMergePatchMovementConfirmation); return; } // /////////////////////////////// MovementConfirmationsControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value); _movementConfirmationApplicationService.When(value as ICreateMovementConfirmation); } catch (Exception ex) { var response = MovementConfirmationsControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }