From f32a65aaea7b134153e4db3435e46ff5fd1a92f6 Mon Sep 17 00:00:00 2001 From: sguming Date: Sun, 11 Aug 2024 05:59:12 +0930 Subject: [PATCH 1/8] Complete --- .gitignore | 1 + blotztask-api/Controllers/TaskController.cs | 5 +++++ blotztask-api/Models/TaskItemDTO.cs | 6 +++++- blotztask-api/Services/TaskService.cs | 16 +++++++++++++++- blotztask-api/appsettings.json | 2 +- 5 files changed, 27 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 9d9eef6..6b97e91 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ *.excalidraw +./vs \ No newline at end of file diff --git a/blotztask-api/Controllers/TaskController.cs b/blotztask-api/Controllers/TaskController.cs index 52ef700..bf9e4dd 100644 --- a/blotztask-api/Controllers/TaskController.cs +++ b/blotztask-api/Controllers/TaskController.cs @@ -18,5 +18,10 @@ public async Task GetAllTask() { return Ok(await _taskService.GetTodoItems()); } + [HttpPost("[action]")] + public async Task GetTaskByID(int ID) + { + return Ok(await _taskService.GetTaskByID(ID-1)); + } } } diff --git a/blotztask-api/Models/TaskItemDTO.cs b/blotztask-api/Models/TaskItemDTO.cs index 287fe1c..617af02 100644 --- a/blotztask-api/Models/TaskItemDTO.cs +++ b/blotztask-api/Models/TaskItemDTO.cs @@ -2,7 +2,11 @@ { public class TaskItemDTO { - public string DisplayId { get; set; } + public int Id { get; set; } public string Title { get; set; } + public string Description { get; set; } + public bool IsDone { get; set; } + public DateTime CreatedAt { get; set; } + public DateTime UpdatedAt { get; set; } } } diff --git a/blotztask-api/Services/TaskService.cs b/blotztask-api/Services/TaskService.cs index f212b95..777b76f 100644 --- a/blotztask-api/Services/TaskService.cs +++ b/blotztask-api/Services/TaskService.cs @@ -7,6 +7,7 @@ namespace BlotzTask.Services; public interface ITaskService { public Task> GetTodoItems(); + public Task GetTaskByID(int ID); } public class TaskService : ITaskService @@ -25,7 +26,7 @@ public async Task> GetTodoItems() return await _dbContext.TaskItems .Select(x => new TaskItemDTO { - DisplayId = $"Task-{x.Id}", + Id = x.Id, Title = x.Title }) .ToListAsync(); @@ -36,5 +37,18 @@ public async Task> GetTodoItems() throw; } } + public async Task GetTaskByID(int ID) + { + + var taskItems = new List + { + new TaskItemDTO { Id = 1, Title = "Task 1", Description = "Description for Task 1", IsDone = false, CreatedAt = DateTime.Now, UpdatedAt = DateTime.Now }, + new TaskItemDTO { Id = 2, Title = "Task 2", Description = "Description for Task 2", IsDone = true, CreatedAt = DateTime.Now, UpdatedAt = DateTime.Now }, + new TaskItemDTO { Id = 3, Title = "Task 3", Description = "Description for Task 3", IsDone = false, CreatedAt = DateTime.Now, UpdatedAt = DateTime.Now } + }; + + return await Task.FromResult(taskItems[ID]); + } + } diff --git a/blotztask-api/appsettings.json b/blotztask-api/appsettings.json index 99d8cc3..d376bc1 100644 --- a/blotztask-api/appsettings.json +++ b/blotztask-api/appsettings.json @@ -1,6 +1,6 @@ { "ConnectionStrings": { - "DefaultConnection": "data source=localhost\\sqlexpress;initial catalog=BlotzTaskAppDb;trusted_connection=true;TrustServerCertificate=True" + "DefaultConnection": "Server=DESKTOP-O3H0KT0;Database=BlotzTaskAppDb;Trusted_Connection=True;TrustServerCertificate=true" }, "Logging": { "LogLevel": { From 8af90ae515443dd6cf34a04acd9a93129869c6a4 Mon Sep 17 00:00:00 2001 From: sguming Date: Sun, 11 Aug 2024 06:11:01 +0930 Subject: [PATCH 2/8] Retore database context --- blotztask-api/appsettings.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/blotztask-api/appsettings.json b/blotztask-api/appsettings.json index d376bc1..99d8cc3 100644 --- a/blotztask-api/appsettings.json +++ b/blotztask-api/appsettings.json @@ -1,6 +1,6 @@ { "ConnectionStrings": { - "DefaultConnection": "Server=DESKTOP-O3H0KT0;Database=BlotzTaskAppDb;Trusted_Connection=True;TrustServerCertificate=true" + "DefaultConnection": "data source=localhost\\sqlexpress;initial catalog=BlotzTaskAppDb;trusted_connection=true;TrustServerCertificate=True" }, "Logging": { "LogLevel": { From 677f2edd38123893c746abc3249fcf03fcba9a0e Mon Sep 17 00:00:00 2001 From: sguming Date: Sun, 11 Aug 2024 19:03:11 +0930 Subject: [PATCH 3/8] ID change --- blotztask-api/Controllers/TaskController.cs | 4 ++-- blotztask-api/Services/TaskService.cs | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/blotztask-api/Controllers/TaskController.cs b/blotztask-api/Controllers/TaskController.cs index bf9e4dd..c3d19da 100644 --- a/blotztask-api/Controllers/TaskController.cs +++ b/blotztask-api/Controllers/TaskController.cs @@ -18,10 +18,10 @@ public async Task GetAllTask() { return Ok(await _taskService.GetTodoItems()); } - [HttpPost("[action]")] + [HttpGet("[action]")] public async Task GetTaskByID(int ID) { - return Ok(await _taskService.GetTaskByID(ID-1)); + return Ok(await _taskService.GetTaskByID(ID)); } } } diff --git a/blotztask-api/Services/TaskService.cs b/blotztask-api/Services/TaskService.cs index 777b76f..53c5dc8 100644 --- a/blotztask-api/Services/TaskService.cs +++ b/blotztask-api/Services/TaskService.cs @@ -42,9 +42,9 @@ public async Task GetTaskByID(int ID) var taskItems = new List { - new TaskItemDTO { Id = 1, Title = "Task 1", Description = "Description for Task 1", IsDone = false, CreatedAt = DateTime.Now, UpdatedAt = DateTime.Now }, - new TaskItemDTO { Id = 2, Title = "Task 2", Description = "Description for Task 2", IsDone = true, CreatedAt = DateTime.Now, UpdatedAt = DateTime.Now }, - new TaskItemDTO { Id = 3, Title = "Task 3", Description = "Description for Task 3", IsDone = false, CreatedAt = DateTime.Now, UpdatedAt = DateTime.Now } + new TaskItemDTO { Id = 0, Title = "Task 0", Description = "Description for Task 1", IsDone = false, CreatedAt = DateTime.Now, UpdatedAt = DateTime.Now }, + new TaskItemDTO { Id = 1, Title = "Task 1", Description = "Description for Task 2", IsDone = true, CreatedAt = DateTime.Now, UpdatedAt = DateTime.Now }, + new TaskItemDTO { Id = 2, Title = "Task 2", Description = "Description for Task 3", IsDone = false, CreatedAt = DateTime.Now, UpdatedAt = DateTime.Now } }; return await Task.FromResult(taskItems[ID]); From 529f4c3bab1edc5e6751e0d879ad5db9ddd6064c Mon Sep 17 00:00:00 2001 From: sguming Date: Tue, 13 Aug 2024 06:12:53 +0930 Subject: [PATCH 4/8] Update route parameter --- blotztask-api/Controllers/TaskController.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/blotztask-api/Controllers/TaskController.cs b/blotztask-api/Controllers/TaskController.cs index c3d19da..9a35e93 100644 --- a/blotztask-api/Controllers/TaskController.cs +++ b/blotztask-api/Controllers/TaskController.cs @@ -18,7 +18,7 @@ public async Task GetAllTask() { return Ok(await _taskService.GetTodoItems()); } - [HttpGet("[action]")] + [HttpGet("{id}")] public async Task GetTaskByID(int ID) { return Ok(await _taskService.GetTaskByID(ID)); From 0068e6ec656b24d607c84a38f188fee161d5b405 Mon Sep 17 00:00:00 2001 From: sguming Date: Tue, 13 Aug 2024 06:13:56 +0930 Subject: [PATCH 5/8] Change name of Parameter --- blotztask-api/Controllers/TaskController.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/blotztask-api/Controllers/TaskController.cs b/blotztask-api/Controllers/TaskController.cs index 9a35e93..1def376 100644 --- a/blotztask-api/Controllers/TaskController.cs +++ b/blotztask-api/Controllers/TaskController.cs @@ -18,7 +18,7 @@ public async Task GetAllTask() { return Ok(await _taskService.GetTodoItems()); } - [HttpGet("{id}")] + [HttpGet("{ID}")] public async Task GetTaskByID(int ID) { return Ok(await _taskService.GetTaskByID(ID)); From 0f88e10a9d993e040b977fc67bb5c6e189fd2f8d Mon Sep 17 00:00:00 2001 From: sguming Date: Tue, 13 Aug 2024 06:18:15 +0930 Subject: [PATCH 6/8] Correct Name --- blotztask-api/Models/TaskItemDTO.cs | 2 +- blotztask-api/Services/TaskService.cs | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/blotztask-api/Models/TaskItemDTO.cs b/blotztask-api/Models/TaskItemDTO.cs index 617af02..264891d 100644 --- a/blotztask-api/Models/TaskItemDTO.cs +++ b/blotztask-api/Models/TaskItemDTO.cs @@ -2,7 +2,7 @@ { public class TaskItemDTO { - public int Id { get; set; } + public int ID { get; set; } public string Title { get; set; } public string Description { get; set; } public bool IsDone { get; set; } diff --git a/blotztask-api/Services/TaskService.cs b/blotztask-api/Services/TaskService.cs index 53c5dc8..cd52884 100644 --- a/blotztask-api/Services/TaskService.cs +++ b/blotztask-api/Services/TaskService.cs @@ -26,7 +26,7 @@ public async Task> GetTodoItems() return await _dbContext.TaskItems .Select(x => new TaskItemDTO { - Id = x.Id, + ID = x.ID, Title = x.Title }) .ToListAsync(); @@ -42,9 +42,9 @@ public async Task GetTaskByID(int ID) var taskItems = new List { - new TaskItemDTO { Id = 0, Title = "Task 0", Description = "Description for Task 1", IsDone = false, CreatedAt = DateTime.Now, UpdatedAt = DateTime.Now }, - new TaskItemDTO { Id = 1, Title = "Task 1", Description = "Description for Task 2", IsDone = true, CreatedAt = DateTime.Now, UpdatedAt = DateTime.Now }, - new TaskItemDTO { Id = 2, Title = "Task 2", Description = "Description for Task 3", IsDone = false, CreatedAt = DateTime.Now, UpdatedAt = DateTime.Now } + new TaskItemDTO { ID = 0, Title = "Task 0", Description = "Description for Task 1", IsDone = false, CreatedAt = DateTime.Now, UpdatedAt = DateTime.Now }, + new TaskItemDTO { ID = 1, Title = "Task 1", Description = "Description for Task 2", IsDone = true, CreatedAt = DateTime.Now, UpdatedAt = DateTime.Now }, + new TaskItemDTO { ID = 2, Title = "Task 2", Description = "Description for Task 3", IsDone = false, CreatedAt = DateTime.Now, UpdatedAt = DateTime.Now } }; return await Task.FromResult(taskItems[ID]); From 8f69186cbe0e024b7b573027a50f5bd0aac56d0c Mon Sep 17 00:00:00 2001 From: sguming Date: Tue, 13 Aug 2024 06:53:29 +0930 Subject: [PATCH 7/8] Name correct --- blotztask-api/Controllers/TaskController.cs | 6 +++--- blotztask-api/Models/TaskItemDTO.cs | 2 +- blotztask-api/Services/TaskService.cs | 14 +++++++------- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/blotztask-api/Controllers/TaskController.cs b/blotztask-api/Controllers/TaskController.cs index 1def376..e0f007e 100644 --- a/blotztask-api/Controllers/TaskController.cs +++ b/blotztask-api/Controllers/TaskController.cs @@ -18,10 +18,10 @@ public async Task GetAllTask() { return Ok(await _taskService.GetTodoItems()); } - [HttpGet("{ID}")] - public async Task GetTaskByID(int ID) + [HttpGet("{Id}")] + public async Task GetTaskByID(int Id) { - return Ok(await _taskService.GetTaskByID(ID)); + return Ok(await _taskService.GetTaskByID(Id)); } } } diff --git a/blotztask-api/Models/TaskItemDTO.cs b/blotztask-api/Models/TaskItemDTO.cs index 264891d..617af02 100644 --- a/blotztask-api/Models/TaskItemDTO.cs +++ b/blotztask-api/Models/TaskItemDTO.cs @@ -2,7 +2,7 @@ { public class TaskItemDTO { - public int ID { get; set; } + public int Id { get; set; } public string Title { get; set; } public string Description { get; set; } public bool IsDone { get; set; } diff --git a/blotztask-api/Services/TaskService.cs b/blotztask-api/Services/TaskService.cs index cd52884..1054ed1 100644 --- a/blotztask-api/Services/TaskService.cs +++ b/blotztask-api/Services/TaskService.cs @@ -7,7 +7,7 @@ namespace BlotzTask.Services; public interface ITaskService { public Task> GetTodoItems(); - public Task GetTaskByID(int ID); + public Task GetTaskByID(int Id); } public class TaskService : ITaskService @@ -26,7 +26,7 @@ public async Task> GetTodoItems() return await _dbContext.TaskItems .Select(x => new TaskItemDTO { - ID = x.ID, + Id = x.Id, Title = x.Title }) .ToListAsync(); @@ -37,17 +37,17 @@ public async Task> GetTodoItems() throw; } } - public async Task GetTaskByID(int ID) + public async Task GetTaskByID(int Id) { var taskItems = new List { - new TaskItemDTO { ID = 0, Title = "Task 0", Description = "Description for Task 1", IsDone = false, CreatedAt = DateTime.Now, UpdatedAt = DateTime.Now }, - new TaskItemDTO { ID = 1, Title = "Task 1", Description = "Description for Task 2", IsDone = true, CreatedAt = DateTime.Now, UpdatedAt = DateTime.Now }, - new TaskItemDTO { ID = 2, Title = "Task 2", Description = "Description for Task 3", IsDone = false, CreatedAt = DateTime.Now, UpdatedAt = DateTime.Now } + new TaskItemDTO { Id = 0, Title = "Task 0", Description = "Description for Task 1", IsDone = false, CreatedAt = DateTime.Now, UpdatedAt = DateTime.Now }, + new TaskItemDTO { Id = 1, Title = "Task 1", Description = "Description for Task 2", IsDone = true, CreatedAt = DateTime.Now, UpdatedAt = DateTime.Now }, + new TaskItemDTO { Id = 2, Title = "Task 2", Description = "Description for Task 3", IsDone = false, CreatedAt = DateTime.Now, UpdatedAt = DateTime.Now } }; - return await Task.FromResult(taskItems[ID]); + return await Task.FromResult(taskItems[Id]); } } From a014b6577c8950c25507d1cb18134588e1851ddb Mon Sep 17 00:00:00 2001 From: sguming Date: Wed, 14 Aug 2024 12:29:38 +0930 Subject: [PATCH 8/8] uppercase --- blotztask-api/Controllers/TaskController.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/blotztask-api/Controllers/TaskController.cs b/blotztask-api/Controllers/TaskController.cs index e0f007e..214e2bf 100644 --- a/blotztask-api/Controllers/TaskController.cs +++ b/blotztask-api/Controllers/TaskController.cs @@ -18,10 +18,10 @@ public async Task GetAllTask() { return Ok(await _taskService.GetTodoItems()); } - [HttpGet("{Id}")] - public async Task GetTaskByID(int Id) + [HttpGet("{id}")] + public async Task GetTaskByID(int id) { - return Ok(await _taskService.GetTaskByID(Id)); + return Ok(await _taskService.GetTaskByID(id)); } } }