public static void SetNullIdOrThrowOnInconsistentIds(string id, CreateOrMergePatchOrDeleteFacilityDto value) { var idObj = id; if (value.FacilityId == null) { value.FacilityId = idObj; } else if (!((ICreateOrMergePatchOrDeleteFacility)value).FacilityId.Equals(idObj)) { throw DomainError.Named("inconsistentId", "Argument Id {0} NOT equals body Id {1}", id, value.FacilityId); } }
public void Put(string id, [FromBody] CreateOrMergePatchOrDeleteFacilityDto value) { try { // /////////////////////////////// if (value.Version != default(long)) { value.CommandType = CommandType.MergePatch; FacilitiesControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value); _facilityApplicationService.When(value as IMergePatchFacility); return; } // /////////////////////////////// FacilitiesControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value); _facilityApplicationService.When(value as ICreateFacility); } catch (Exception ex) { var response = FacilitiesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }