public async Task WhenAsync(MergePatchDamageReasonDto c)
        {
            var idObj         = (c as IMergePatchDamageReason).DamageReasonId;
            var uriParameters = new DamageReasonUriParameters();

            uriParameters.Id = idObj;

            var req  = new DamageReasonPatchRequest(uriParameters, (MergePatchDamageReasonDto)c);
            var resp = await _ramlClient.DamageReason.Patch(req);

            DamageReasonProxyUtils.ThrowOnHttpResponseError(resp);
        }
        public async Task <IDamageReasonState> GetHistoryStateAsync(string damageReasonId, long version)
        {
            var idObj         = damageReasonId;
            var uriParameters = new DamageReasonHistoryStateUriParameters();

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

            var req  = new DamageReasonHistoryStateGetRequest(uriParameters);
            var resp = await _ramlClient.DamageReasonHistoryState.Get(req);

            DamageReasonProxyUtils.ThrowOnHttpResponseError(resp);
            return((resp.Content == null) ? null : resp.Content.ToDamageReasonState());
        }
        public async Task <IDamageReasonEvent> GetStateEventAsync(string damageReasonId, long version)
        {
            var idObj         = damageReasonId;
            var uriParameters = new DamageReasonStateEventUriParameters();

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

            var req  = new DamageReasonStateEventGetRequest(uriParameters);
            var resp = await _ramlClient.DamageReasonStateEvent.Get(req);

            DamageReasonProxyUtils.ThrowOnHttpResponseError(resp);
            return(resp.Content);
        }
        public async Task <IDamageReasonState> GetAsync(string damageReasonId)
        {
            IDamageReasonState state = null;
            var idObj         = damageReasonId;
            var uriParameters = new DamageReasonUriParameters();

            uriParameters.Id = idObj;

            var req = new DamageReasonGetRequest(uriParameters);

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

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

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

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

            DamageReasonProxyUtils.ThrowOnHttpResponseError(resp);
            states = (resp.Content == null) ? null : resp.Content.Select(e => e.ToDamageReasonState());
            return(states);
        }
        public async Task WhenAsync(DeleteDamageReasonDto c)
        {
            var idObj         = (c as IDeleteDamageReason).DamageReasonId;
            var uriParameters = new DamageReasonUriParameters();

            uriParameters.Id = idObj;

            var q = new DamageReasonDeleteQuery();

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

            var req = new DamageReasonDeleteRequest(uriParameters);

            req.Query = q;

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

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

            q.Filter = DamageReasonProxyUtils.GetFilterQueryValueString(filter);
            var req = new DamageReasonsCountGetRequest();

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

            DamageReasonProxyUtils.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));
        }