public async Task WhenAsync(MergePatchPartyRoleDto c)
        {
            var idObj         = PartyRoleProxyUtils.ToIdString((c as IMergePatchPartyRole).PartyRoleId);
            var uriParameters = new PartyRoleUriParameters();

            uriParameters.Id = idObj;

            var req  = new PartyRolePatchRequest(uriParameters, (MergePatchPartyRoleDto)c);
            var resp = await _ramlClient.PartyRole.Patch(req);

            PartyRoleProxyUtils.ThrowOnHttpResponseError(resp);
        }
        public async Task <IPartyRoleState> GetHistoryStateAsync(PartyRoleId partyRoleId, long version)
        {
            var idObj         = PartyRoleProxyUtils.ToIdString(partyRoleId);
            var uriParameters = new PartyRoleHistoryStateUriParameters();

            uriParameters.Id      = idObj;
            uriParameters.Version = version.ToString();

            var req  = new PartyRoleHistoryStateGetRequest(uriParameters);
            var resp = await _ramlClient.PartyRoleHistoryState.Get(req);

            PartyRoleProxyUtils.ThrowOnHttpResponseError(resp);
            return((resp.Content == null) ? null : resp.Content.ToPartyRoleState());
        }
        public async Task <IPartyRoleEvent> GetStateEventAsync(PartyRoleId partyRoleId, long version)
        {
            var idObj         = PartyRoleProxyUtils.ToIdString(partyRoleId);
            var uriParameters = new PartyRoleStateEventUriParameters();

            uriParameters.Id      = idObj;
            uriParameters.Version = version.ToString();

            var req  = new PartyRoleStateEventGetRequest(uriParameters);
            var resp = await _ramlClient.PartyRoleStateEvent.Get(req);

            PartyRoleProxyUtils.ThrowOnHttpResponseError(resp);
            return(resp.Content);
        }
        public async Task <IPartyRoleState> GetAsync(PartyRoleId partyRoleId)
        {
            IPartyRoleState state         = null;
            var             idObj         = PartyRoleProxyUtils.ToIdString(partyRoleId);
            var             uriParameters = new PartyRoleUriParameters();

            uriParameters.Id = idObj;

            var req = new PartyRoleGetRequest(uriParameters);

            var resp = await _ramlClient.PartyRole.Get(req);

            PartyRoleProxyUtils.ThrowOnHttpResponseError(resp);
            state = (resp.Content == null) ? null : resp.Content.ToPartyRoleState();
            return(state);
        }
        public async Task <IEnumerable <IPartyRoleState> > GetAsync(ICriterion filter, IList <string> orders = null, int firstResult = 0, int maxResults = int.MaxValue, IList <string> fields = null)
        {
            IEnumerable <IPartyRoleState> states = null;
            var q = new PartyRolesGetQuery();

            q.FirstResult = firstResult;
            q.MaxResults  = maxResults;
            q.Sort        = PartyRoleProxyUtils.GetOrdersQueryValueString(orders);
            q.Fields      = PartyRoleProxyUtils.GetReturnedFieldsQueryValueString(fields, QueryFieldValueSeparator);
            q.Filter      = PartyRoleProxyUtils.GetFilterQueryValueString(filter);
            var req = new PartyRolesGetRequest();

            req.Query = q;
            var resp = await _ramlClient.PartyRoles.Get(req);

            PartyRoleProxyUtils.ThrowOnHttpResponseError(resp);
            states = (resp.Content == null) ? null : resp.Content.Select(e => e.ToPartyRoleState());
            return(states);
        }
        public async Task WhenAsync(DeletePartyRoleDto c)
        {
            var idObj         = PartyRoleProxyUtils.ToIdString((c as IDeletePartyRole).PartyRoleId);
            var uriParameters = new PartyRoleUriParameters();

            uriParameters.Id = idObj;

            var q = new PartyRoleDeleteQuery();

            q.CommandId   = c.CommandId;
            q.RequesterId = c.RequesterId;
            q.Version     = Convert.ToString(c.Version);

            var req = new PartyRoleDeleteRequest(uriParameters);

            req.Query = q;

            var resp = await _ramlClient.PartyRole.Delete(req);

            PartyRoleProxyUtils.ThrowOnHttpResponseError(resp);
        }
        public async virtual Task <long> GetCountAsync(ICriterion filter)
        {
            var q = new PartyRolesCountGetQuery();

            q.Filter = PartyRoleProxyUtils.GetFilterQueryValueString(filter);
            var req = new PartyRolesCountGetRequest();

            req.Query = q;
            var resp = await _ramlClient.PartyRolesCount.Get(req);

            PartyRoleProxyUtils.ThrowOnHttpResponseError(resp);
            string str = await resp.RawContent.ReadAsStringAsync();

            if (str.StartsWith("\""))
            {
                str = str.Substring(1);
            }
            if (str.EndsWith("\""))
            {
                str = str.Substring(0, str.Length - 1);
            }
            return(long.Parse(str));
        }