Add created
This commit is contained in:
parent
2506324cfd
commit
4f3b19891a
@ -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),
|
||||
|
@ -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);
|
||||
}
|
@ -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; }
|
||||
}
|
@ -6,7 +6,8 @@ public interface ITodoRepository
|
||||
string title,
|
||||
string? projectName,
|
||||
string? description,
|
||||
string userId);
|
||||
string userId,
|
||||
long created);
|
||||
|
||||
Task<IEnumerable<Entities.Todo>> GetTodosAsync();
|
||||
|
||||
|
@ -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;
|
||||
}
|
@ -18,16 +18,18 @@ public class TodoRepository : ITodoRepository
|
||||
|
||||
public async Task<Core.Entities.Todo> 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
|
||||
};
|
||||
}
|
||||
}
|
@ -20,6 +20,7 @@ export const TodoList = (props: {
|
||||
|
||||
return t.status == false;
|
||||
})
|
||||
.sort((a, b) => a.created - b.created)
|
||||
.map((t, i) => (
|
||||
<li key={i}>
|
||||
<TodoItem
|
||||
|
@ -13,6 +13,7 @@ export interface Todo {
|
||||
status: StatusState;
|
||||
project?: string;
|
||||
authorId?: string;
|
||||
created: number;
|
||||
}
|
||||
|
||||
export const asTodo = (item: Todo): Todo => {
|
||||
|
Loading…
Reference in New Issue
Block a user