Example #1
0
        public async Task Update(Todo todo)
        {
            var rawJson = JsonConvert.SerializeObject(todo);
            var serviceResponse = await RestClient.Put(String.Format(TodoUrl + "{0}", todo.TodoId), rawJson);

            if (serviceResponse.StatusCode != HttpStatusCode.OK)
                throw new Exception("Ne mogu izmjeniti postojeći TODO. \n\nDetalji : " + serviceResponse.Content);
        }
Example #2
0
        public async Task<Todo> Create(Todo todo)
        {
            var rawJson = JsonConvert.SerializeObject(todo);
            var serviceResponse = await RestClient.Post(TodoUrl, rawJson);

            if (serviceResponse.StatusCode != HttpStatusCode.Created)
                throw new Exception("Ne mogu dodati novi TODO. \n\nDetalji : " + serviceResponse.Content);

            return JsonConvert.DeserializeObject<Todo>(serviceResponse.Content);
        }