public static void SetNullIdOrThrowOnInconsistentIds(string id, CreateOrMergePatchOrDeleteContactMechDto value) { var idObj = id; if (value.ContactMechId == null) { value.ContactMechId = idObj; } else if (!((ICreateOrMergePatchOrDeleteContactMech)value).ContactMechId.Equals(idObj)) { throw DomainError.Named("inconsistentId", "Argument Id {0} NOT equals body Id {1}", id, value.ContactMechId); } }
public void Put(string id, [FromBody] CreateOrMergePatchOrDeleteContactMechDto value) { try { // /////////////////////////////// if (value.Version != default(long)) { value.CommandType = CommandType.MergePatch; ContactMechesControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value); _contactMechApplicationService.When(value as IMergePatchContactMech); return; } // /////////////////////////////// ContactMechesControllerUtils.SetNullIdOrThrowOnInconsistentIds(id, value); _contactMechApplicationService.When(value as ICreateContactMech); } catch (Exception ex) { var response = ContactMechesControllerUtils.GetErrorHttpResponseMessage(ex); throw new HttpResponseException(response); } }