public static async void UpdateTodo(TodoModel todoModel) { var json = JsonConvert.SerializeObject(todoModel); using (var content = new StringContent(json, Encoding.UTF8, "application/json")) { var respones = await ApiHelper.client.PutAsync("todo/" + todoModel._id, content); respones.EnsureSuccessStatusCode(); } }
public IActionResult UpdateTodo(Models.TodoModel todoModel) { if (ModelState.IsValid) { var todo = new TodoDataLibrary.TodoModel(); todo._id = todoModel.ID; todo.title = todoModel.Title; todo.desc = todoModel.Desc; todo.estimate = todoModel.Estimate; TodoProcessor.UpdateTodo(todo); return(RedirectToAction("Todo", "Home", new { id = todo._id })); } return(View()); }
public static async void TimeSpent(TodoModel todoModel) { var timespent = new PostTimeSpent(); timespent.timespent = todoModel.timespent[0].timespent; timespent.desc = todoModel.timespent[0].desc; var json = JsonConvert.SerializeObject(timespent); using (var content = new StringContent(json, Encoding.UTF8, "application/json")) { var respones = await ApiHelper.client.PutAsync("todo/" + todoModel._id + "/timespent", content); respones.EnsureSuccessStatusCode(); } }
public IActionResult TimeSpent(Models.Timespent timespentModel) { if (ModelState.IsValid) { var timespent = new TodoDataLibrary.Timespent(); var todo = new TodoDataLibrary.TodoModel(); timespent.timespent = timespentModel.timespent; timespent.desc = timespentModel.desc; todo._id = timespentModel.ID; todo.timespent = new List <TodoDataLibrary.Timespent>(); todo.timespent.Add(timespent); TodoProcessor.TimeSpent(todo); return(RedirectToAction("Todo", "Home", new { id = timespentModel.ID })); } return(View()); }
public static async Task <TodoModel> LoadTodo(string id) { using (HttpResponseMessage response = await ApiHelper.client.GetAsync("todo/" + id)) { if (response.IsSuccessStatusCode) { var rawJsonString = await response.Content.ReadAsStringAsync(); TodoModel todo = JsonConvert.DeserializeObject <TodoModel>(rawJsonString); return(todo); } else { throw new Exception(response.ReasonPhrase); } } }