private async Task updateCommand() { item = new Todomodel(); item.task = task; item.description = description; item.Done = Done; item.todoId = id; bool res; try { res = await toDoService.PutTodo(item); } catch (Exception ex) { res = false; } }
async public Task <bool> PostTodo(Todomodel item) { try { var itemtosend = JsonConvert.SerializeObject(item); var content = new StringContent(itemtosend, Encoding.UTF8, "application/json"); var result = await httpclient.PostAsync("Todo", content); if (result.IsSuccessStatusCode) { return(true); } return(false); } catch (Exception e) { return(false); } }
public IActionResult Put([FromBody] Todomodel TodoModel) { if (TodoModel == null) { return(BadRequest("Todo is Null")); } _itodorepository.Update(TodoModel); return(Ok(TodoModel)); }
public IActionResult Get(int id) { Todomodel TodoModel = _itodorepository.Find(id); if (TodoModel == null) { return(NotFound("No Hotel")); } return(Ok(TodoModel)); }
public IActionResult Post([FromBody] Todomodel TodoModel) { if (TodoModel == null) { return(BadRequest("No Hotel")); } if (ModelState.IsValid) { _itodorepository.Add(TodoModel); return(Ok(TodoModel)); } return(BadRequest("Invalid Entries")); }