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