public async Task WhenAsync(MergePatchDamageTypeDto c)
        {
            var idObj         = (c as IMergePatchDamageType).DamageTypeId;
            var uriParameters = new DamageTypeUriParameters();

            uriParameters.Id = idObj;

            var req  = new DamageTypePatchRequest(uriParameters, (MergePatchDamageTypeDto)c);
            var resp = await _ramlClient.DamageType.Patch(req);

            DamageTypeProxyUtils.ThrowOnHttpResponseError(resp);
        }
        public async Task <IDamageTypeState> GetHistoryStateAsync(string damageTypeId, long version)
        {
            var idObj         = damageTypeId;
            var uriParameters = new DamageTypeHistoryStateUriParameters();

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

            var req  = new DamageTypeHistoryStateGetRequest(uriParameters);
            var resp = await _ramlClient.DamageTypeHistoryState.Get(req);

            DamageTypeProxyUtils.ThrowOnHttpResponseError(resp);
            return((resp.Content == null) ? null : resp.Content.ToDamageTypeState());
        }
        public async Task <IDamageTypeEvent> GetStateEventAsync(string damageTypeId, long version)
        {
            var idObj         = damageTypeId;
            var uriParameters = new DamageTypeStateEventUriParameters();

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

            var req  = new DamageTypeStateEventGetRequest(uriParameters);
            var resp = await _ramlClient.DamageTypeStateEvent.Get(req);

            DamageTypeProxyUtils.ThrowOnHttpResponseError(resp);
            return(resp.Content);
        }
        public async Task <IDamageTypeState> GetAsync(string damageTypeId)
        {
            IDamageTypeState state = null;
            var idObj         = damageTypeId;
            var uriParameters = new DamageTypeUriParameters();

            uriParameters.Id = idObj;

            var req = new DamageTypeGetRequest(uriParameters);

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

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

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

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

            DamageTypeProxyUtils.ThrowOnHttpResponseError(resp);
            states = (resp.Content == null) ? null : resp.Content.Select(e => e.ToDamageTypeState());
            return(states);
        }
        public async Task WhenAsync(DeleteDamageTypeDto c)
        {
            var idObj         = (c as IDeleteDamageType).DamageTypeId;
            var uriParameters = new DamageTypeUriParameters();

            uriParameters.Id = idObj;

            var q = new DamageTypeDeleteQuery();

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

            var req = new DamageTypeDeleteRequest(uriParameters);

            req.Query = q;

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

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

            q.Filter = DamageTypeProxyUtils.GetFilterQueryValueString(filter);
            var req = new DamageTypesCountGetRequest();

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

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