Exemple #1
0
        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."));
        }
Exemple #2
0
        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"));
        }