コード例 #1
0
ファイル: TodoService.cs プロジェクト: ksingh1129/playgroud
        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."));
        }
コード例 #2
0
ファイル: TodoService.cs プロジェクト: ksingh1129/playgroud
        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"));
        }