Beispiel #1
0
        public ToDo Insert(ToDo entity)
        {
            HttpContent content = new StringContent(JsonConvert.SerializeObject(entity));

            content.Headers.ContentType = new MediaTypeHeaderValue("application/json");

            HttpResponseMessage responseMessage = _httpClient.PostAsync($"todo/", content).Result;

            responseMessage.EnsureSuccessStatusCode();

            string json = responseMessage.Content.ReadAsStringAsync().Result;

            G.ToDo newToDo = JsonConvert.DeserializeObject <G.ToDo>(json);
            return(newToDo.ToClient());
        }
Beispiel #2
0
 internal static ToDo ToClient(this G.ToDo entity)
 {
     return(new ToDo(entity.Id, entity.Title, entity.Description, entity.Done, entity.ValidationDate, entity.UserId));
 }