diff --git a/src/backend/server/src/Todo.Core/Application/Commands/Todo/CreateTodoCommand.cs b/src/backend/server/src/Todo.Core/Application/Commands/Todo/CreateTodoCommand.cs index 920b428..84880c7 100644 --- a/src/backend/server/src/Todo.Core/Application/Commands/Todo/CreateTodoCommand.cs +++ b/src/backend/server/src/Todo.Core/Application/Commands/Todo/CreateTodoCommand.cs @@ -40,7 +40,8 @@ public record CreateTodoCommand( request.TodoTitle, request.TodoProject, request.TodoDescription, - userId); + userId, + DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()); await _mediator.Publish( new TodoCreated(todo.Id), diff --git a/src/backend/server/src/Todo.Core/Application/Queries/Todos/TodoViewModel.cs b/src/backend/server/src/Todo.Core/Application/Queries/Todos/TodoViewModel.cs index cd5e448..f6a259c 100644 --- a/src/backend/server/src/Todo.Core/Application/Queries/Todos/TodoViewModel.cs +++ b/src/backend/server/src/Todo.Core/Application/Queries/Todos/TodoViewModel.cs @@ -6,7 +6,8 @@ public record TodoViewModel( bool Status, string AuthorId, string? Project, - string? Description + string? Description, + long Created ) { internal static TodoViewModel From(Entities.Todo t) => new( @@ -15,5 +16,6 @@ public record TodoViewModel( t.Status, t.AuthorId, t.Project, - t.Description); + t.Description, + t.Created); } \ No newline at end of file diff --git a/src/backend/server/src/Todo.Core/Entities/Todo.cs b/src/backend/server/src/Todo.Core/Entities/Todo.cs index fcc52b2..b3df207 100644 --- a/src/backend/server/src/Todo.Core/Entities/Todo.cs +++ b/src/backend/server/src/Todo.Core/Entities/Todo.cs @@ -8,4 +8,5 @@ public record Todo public string? Project { get; init; } public string AuthorId { get; init; } public string? Description { get; init; } + public long Created { get; init; } } \ No newline at end of file diff --git a/src/backend/server/src/Todo.Core/Interfaces/Persistence/ITodoRepository.cs b/src/backend/server/src/Todo.Core/Interfaces/Persistence/ITodoRepository.cs index 8aef0ee..ec355f9 100644 --- a/src/backend/server/src/Todo.Core/Interfaces/Persistence/ITodoRepository.cs +++ b/src/backend/server/src/Todo.Core/Interfaces/Persistence/ITodoRepository.cs @@ -6,7 +6,8 @@ public interface ITodoRepository string title, string? projectName, string? description, - string userId); + string userId, + long created); Task> GetTodosAsync(); diff --git a/src/backend/server/src/Todo.Persistence/Mongo/Repositories/Dtos/MongoTodo.cs b/src/backend/server/src/Todo.Persistence/Mongo/Repositories/Dtos/MongoTodo.cs index 8292af2..70725a3 100644 --- a/src/backend/server/src/Todo.Persistence/Mongo/Repositories/Dtos/MongoTodo.cs +++ b/src/backend/server/src/Todo.Persistence/Mongo/Repositories/Dtos/MongoTodo.cs @@ -19,4 +19,5 @@ public record MongoTodo public string? ProjectName { get; set; } = string.Empty; public string AuthorId { get; set; } + public long Created { get; set; } = 0; } \ No newline at end of file diff --git a/src/backend/server/src/Todo.Persistence/Mongo/Repositories/TodoRepository.cs b/src/backend/server/src/Todo.Persistence/Mongo/Repositories/TodoRepository.cs index 3dc8211..fb71d76 100644 --- a/src/backend/server/src/Todo.Persistence/Mongo/Repositories/TodoRepository.cs +++ b/src/backend/server/src/Todo.Persistence/Mongo/Repositories/TodoRepository.cs @@ -18,16 +18,18 @@ public class TodoRepository : ITodoRepository public async Task CreateTodoAsync( string title, - string projectName, + string? projectName, string? description, - string userId) + string userId, + long created) { var todo = new MongoTodo { Title = title, ProjectName = projectName, AuthorId = userId, - Description = description + Description = description, + Created = created }; await _todosCollection.InsertOneAsync(todo); return new Core.Entities.Todo @@ -37,7 +39,8 @@ public class TodoRepository : ITodoRepository Status = false, Project = todo.ProjectName, Description = todo.Description, - AuthorId = todo.AuthorId + AuthorId = todo.AuthorId, + Created = todo.Created }; } @@ -55,7 +58,8 @@ public class TodoRepository : ITodoRepository Status = t.Status, Project = t.ProjectName, Description = t.Description, - AuthorId = t.AuthorId + AuthorId = t.AuthorId, + Created = t.Created }); } @@ -88,7 +92,8 @@ public class TodoRepository : ITodoRepository Status = todo.Status, Title = todo.Title, Description = todo.Description, - AuthorId = todo.AuthorId + AuthorId = todo.AuthorId, + Created = todo.Created }; } @@ -104,7 +109,8 @@ public class TodoRepository : ITodoRepository Title = todo.Title, ProjectName = todo.Project, AuthorId = todo.AuthorId, - Description = todo.Description + Description = todo.Description, + Created = todo.Created }); return new Core.Entities.Todo @@ -114,7 +120,8 @@ public class TodoRepository : ITodoRepository Status = updatedTodo.Status, Title = updatedTodo.Title, AuthorId = updatedTodo.AuthorId, - Description = updatedTodo.Description + Description = updatedTodo.Description, + Created = updatedTodo.Created }; } } \ No newline at end of file diff --git a/src/client/src/components/todos/todoList.tsx b/src/client/src/components/todos/todoList.tsx index a67288f..36e8495 100644 --- a/src/client/src/components/todos/todoList.tsx +++ b/src/client/src/components/todos/todoList.tsx @@ -20,6 +20,7 @@ export const TodoList = (props: { return t.status == false; }) + .sort((a, b) => a.created - b.created) .map((t, i) => (
  • {