public IActionResult UpdateTodoItem(TodoItem todoItem) { var jsonFileService = new JsonFileService(); string filePath = "Source/resource.json"; var todoItemJsonString = jsonFileService.UpdateTodoItemJsonFile(todoItem, filePath); if (!string.IsNullOrEmpty(todoItemJsonString)) { File.WriteAllText(filePath, todoItemJsonString); return(new OkObjectResult("Update Success")); } return(new NotFoundObjectResult("TodoItem is not found.")); }
public IActionResult CreateTodoItem(TodoItem todoItem) { var jsonFileService = new JsonFileService(); string filePath = "Source/resource.json"; var todoItemJsonString = jsonFileService.CreateTodoItemJsonFile(todoItem, filePath); if (!string.IsNullOrEmpty(todoItemJsonString)) { File.WriteAllText(filePath, todoItemJsonString); return(new OkObjectResult("Create Success")); } return(new BadRequestObjectResult("Can't create new TodoItem")); }