Exemplo n.º 1
0
        public async Task Delete(int id)
        {
            HttpResponseMessage response = await RestClientSingleton.Instance().DeleteAsync("api/TodoItems/" + id);

            string responseText = await response.Content.ReadAsStringAsync();

            response.Dispose();

            if (!response.IsSuccessStatusCode)
            {
                throw new Exception(responseText);
            }
        }
Exemplo n.º 2
0
        public async Task Update(int id, TEntity entity)
        {
            HttpContent         content  = new StringContent(JsonConvert.SerializeObject(entity), Encoding.UTF8, "application/json");
            HttpResponseMessage response = await RestClientSingleton.Instance().PutAsync("api/TodoItems/" + id, content);

            string responseText = await response.Content.ReadAsStringAsync();

            response.Dispose();

            if (!response.IsSuccessStatusCode)
            {
                throw new Exception(responseText);
            }
        }
Exemplo n.º 3
0
        public async Task <List <TEntity> > GetAll()
        {
            HttpResponseMessage response = await RestClientSingleton.Instance().GetAsync("api/TodoItems");

            string responseText = await response.Content.ReadAsStringAsync();

            response.Dispose();

            if (!response.IsSuccessStatusCode)
            {
                throw new Exception(responseText);
            }

            return(JsonConvert.DeserializeObject <List <TEntity> >(responseText));
        }