Esempio n. 1
0
        /**
         * Entity Function call (a service operation that returns entities and has no side effects)
         */
        public async Task <JToken> CallEntityFunctionAsync(string functionName, Dictionary <string, object> paramsObject, QueryObject queryObject, string returnTypeName, bool returnCollection)
        {
            queryObject.Count = returnCollection;
            var paramsQueryString = DataAdapterUtils.CreateParamsQueryString(paramsObject);

            var url = this.apiUrl + "/operations/" + functionName + "?" + paramsQueryString + "&" + QueryUtils.RenderQueryString(queryObject);

            var response = await this.client.GetAsync(url);

            if (response.IsSuccessStatusCode)
            {
                var json = await response.Content.ReadAsStringAsync();

                var resultToken = JToken.Parse(json);
                return(resultToken);
            }
            return(null);
        }
Esempio n. 2
0
        /**
         * Delete multiple entities
         */
        public async Task <JToken> DeleteItemsAsync(string entityTypeName, Dto[] items)
        {
            var entitySetName = this.metadataCli.EntityTypes[entityTypeName].EntitySetName;
            var keyNames      = this.metadataCli.EntityTypes[entityTypeName].Key;
            var url           = this.apiUrl + "/crud/" + "batch/" + entitySetName + "?" + QueryUtils.RenderQueryString(new QueryObject()
            {
                Keys = DataAdapterUtils.GetKeyFromMultipleData(keyNames, items).ToArray()
            });

            var response = await this.client.DeleteAsync(url);

            if (response.IsSuccessStatusCode)
            {
                var json = await response.Content.ReadAsStringAsync();

                var resultSerialDataToken = JToken.Parse(json);
                return(resultSerialDataToken);
            }
            return(null);
        }