Add created
This commit is contained in:
parent
2506324cfd
commit
4f3b19891a
@ -40,7 +40,8 @@ public record CreateTodoCommand(
|
|||||||
request.TodoTitle,
|
request.TodoTitle,
|
||||||
request.TodoProject,
|
request.TodoProject,
|
||||||
request.TodoDescription,
|
request.TodoDescription,
|
||||||
userId);
|
userId,
|
||||||
|
DateTimeOffset.UtcNow.ToUnixTimeMilliseconds());
|
||||||
|
|
||||||
await _mediator.Publish(
|
await _mediator.Publish(
|
||||||
new TodoCreated(todo.Id),
|
new TodoCreated(todo.Id),
|
||||||
|
@ -6,7 +6,8 @@ public record TodoViewModel(
|
|||||||
bool Status,
|
bool Status,
|
||||||
string AuthorId,
|
string AuthorId,
|
||||||
string? Project,
|
string? Project,
|
||||||
string? Description
|
string? Description,
|
||||||
|
long Created
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
internal static TodoViewModel From(Entities.Todo t) => new(
|
internal static TodoViewModel From(Entities.Todo t) => new(
|
||||||
@ -15,5 +16,6 @@ public record TodoViewModel(
|
|||||||
t.Status,
|
t.Status,
|
||||||
t.AuthorId,
|
t.AuthorId,
|
||||||
t.Project,
|
t.Project,
|
||||||
t.Description);
|
t.Description,
|
||||||
|
t.Created);
|
||||||
}
|
}
|
@ -8,4 +8,5 @@ public record Todo
|
|||||||
public string? Project { get; init; }
|
public string? Project { get; init; }
|
||||||
public string AuthorId { get; init; }
|
public string AuthorId { get; init; }
|
||||||
public string? Description { get; init; }
|
public string? Description { get; init; }
|
||||||
|
public long Created { get; init; }
|
||||||
}
|
}
|
@ -6,7 +6,8 @@ public interface ITodoRepository
|
|||||||
string title,
|
string title,
|
||||||
string? projectName,
|
string? projectName,
|
||||||
string? description,
|
string? description,
|
||||||
string userId);
|
string userId,
|
||||||
|
long created);
|
||||||
|
|
||||||
Task<IEnumerable<Entities.Todo>> GetTodosAsync();
|
Task<IEnumerable<Entities.Todo>> GetTodosAsync();
|
||||||
|
|
||||||
|
@ -19,4 +19,5 @@ public record MongoTodo
|
|||||||
|
|
||||||
public string? ProjectName { get; set; } = string.Empty;
|
public string? ProjectName { get; set; } = string.Empty;
|
||||||
public string AuthorId { get; set; }
|
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(
|
public async Task<Core.Entities.Todo> CreateTodoAsync(
|
||||||
string title,
|
string title,
|
||||||
string projectName,
|
string? projectName,
|
||||||
string? description,
|
string? description,
|
||||||
string userId)
|
string userId,
|
||||||
|
long created)
|
||||||
{
|
{
|
||||||
var todo = new MongoTodo
|
var todo = new MongoTodo
|
||||||
{
|
{
|
||||||
Title = title,
|
Title = title,
|
||||||
ProjectName = projectName,
|
ProjectName = projectName,
|
||||||
AuthorId = userId,
|
AuthorId = userId,
|
||||||
Description = description
|
Description = description,
|
||||||
|
Created = created
|
||||||
};
|
};
|
||||||
await _todosCollection.InsertOneAsync(todo);
|
await _todosCollection.InsertOneAsync(todo);
|
||||||
return new Core.Entities.Todo
|
return new Core.Entities.Todo
|
||||||
@ -37,7 +39,8 @@ public class TodoRepository : ITodoRepository
|
|||||||
Status = false,
|
Status = false,
|
||||||
Project = todo.ProjectName,
|
Project = todo.ProjectName,
|
||||||
Description = todo.Description,
|
Description = todo.Description,
|
||||||
AuthorId = todo.AuthorId
|
AuthorId = todo.AuthorId,
|
||||||
|
Created = todo.Created
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,7 +58,8 @@ public class TodoRepository : ITodoRepository
|
|||||||
Status = t.Status,
|
Status = t.Status,
|
||||||
Project = t.ProjectName,
|
Project = t.ProjectName,
|
||||||
Description = t.Description,
|
Description = t.Description,
|
||||||
AuthorId = t.AuthorId
|
AuthorId = t.AuthorId,
|
||||||
|
Created = t.Created
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,7 +92,8 @@ public class TodoRepository : ITodoRepository
|
|||||||
Status = todo.Status,
|
Status = todo.Status,
|
||||||
Title = todo.Title,
|
Title = todo.Title,
|
||||||
Description = todo.Description,
|
Description = todo.Description,
|
||||||
AuthorId = todo.AuthorId
|
AuthorId = todo.AuthorId,
|
||||||
|
Created = todo.Created
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,7 +109,8 @@ public class TodoRepository : ITodoRepository
|
|||||||
Title = todo.Title,
|
Title = todo.Title,
|
||||||
ProjectName = todo.Project,
|
ProjectName = todo.Project,
|
||||||
AuthorId = todo.AuthorId,
|
AuthorId = todo.AuthorId,
|
||||||
Description = todo.Description
|
Description = todo.Description,
|
||||||
|
Created = todo.Created
|
||||||
});
|
});
|
||||||
|
|
||||||
return new Core.Entities.Todo
|
return new Core.Entities.Todo
|
||||||
@ -114,7 +120,8 @@ public class TodoRepository : ITodoRepository
|
|||||||
Status = updatedTodo.Status,
|
Status = updatedTodo.Status,
|
||||||
Title = updatedTodo.Title,
|
Title = updatedTodo.Title,
|
||||||
AuthorId = updatedTodo.AuthorId,
|
AuthorId = updatedTodo.AuthorId,
|
||||||
Description = updatedTodo.Description
|
Description = updatedTodo.Description,
|
||||||
|
Created = updatedTodo.Created
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -20,6 +20,7 @@ export const TodoList = (props: {
|
|||||||
|
|
||||||
return t.status == false;
|
return t.status == false;
|
||||||
})
|
})
|
||||||
|
.sort((a, b) => a.created - b.created)
|
||||||
.map((t, i) => (
|
.map((t, i) => (
|
||||||
<li key={i}>
|
<li key={i}>
|
||||||
<TodoItem
|
<TodoItem
|
||||||
|
@ -13,6 +13,7 @@ export interface Todo {
|
|||||||
status: StatusState;
|
status: StatusState;
|
||||||
project?: string;
|
project?: string;
|
||||||
authorId?: string;
|
authorId?: string;
|
||||||
|
created: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const asTodo = (item: Todo): Todo => {
|
export const asTodo = (item: Todo): Todo => {
|
||||||
|
Loading…
Reference in New Issue
Block a user