Esempio n. 1
0
        public async Task <List <T> > GetAll(bool deleted)
        {
            Dictionary <string, string> args = new Dictionary <string, string>(this.args);

            args.Add("deleted", deleted.ToString());

            HttpResponseMessage response = await httpClient.GetAsync(name + "?" + UrlArgsUtil.makeArgs(args));

            return((response.IsSuccessStatusCode)
                ? await response.Content.ReadAsAsync <List <T> >()
                : throw ApiException.Create(await response.Content.ReadAsAsync <ErrorType>()));
        }
Esempio n. 2
0
        public async Task Update(int id, T item)
        {
            HttpResponseMessage response = await httpClient.PutAsJsonAsync(name + "/" + id + "?" + UrlArgsUtil.makeArgs(args), item);

            if (!response.IsSuccessStatusCode)
            {
                throw ApiException.Create(await response.Content.ReadAsAsync <ErrorType>());
            }
        }
Esempio n. 3
0
        public async Task <T> Add(T item)
        {
            HttpResponseMessage response = await httpClient.PostAsJsonAsync(name + "?" + UrlArgsUtil.makeArgs(args), item);

            return((response.IsSuccessStatusCode)
                 ? await response.Content.ReadAsAsync <T>()
                 : throw ApiException.Create(await response.Content.ReadAsAsync <ErrorType>()));
        }
Esempio n. 4
0
        public async Task <T> Get(int id)
        {
            HttpResponseMessage response = await httpClient.GetAsync(name + "/" + id + "?" + UrlArgsUtil.makeArgs(args));

            return((response.IsSuccessStatusCode)
                ? await response.Content.ReadAsAsync <T>()
                : throw ApiException.Create(await response.Content.ReadAsAsync <ErrorType>()));
        }