Add priority
This commit is contained in:
@@ -28,24 +28,24 @@ public class TodosController : ApiController
|
||||
[JsonPropertyName("project")]
|
||||
public string? Project { get; init; }
|
||||
|
||||
[JsonPropertyName("priority")]
|
||||
public string? Priority { get; init; }
|
||||
|
||||
internal CreateTodoCommand To() => new(
|
||||
Title,
|
||||
Project,
|
||||
Description);
|
||||
Description,
|
||||
Priority);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<ActionResult<string>> CreateTodo(
|
||||
[FromBody] CreateTodoRequest request)
|
||||
{
|
||||
return Ok(await Mediator.Send(request.To()));
|
||||
}
|
||||
=> Ok(await Mediator.Send(request.To()));
|
||||
|
||||
[HttpGet("{todoId}")]
|
||||
public async Task<ActionResult<TodoViewModel>> GetTodoById([FromRoute] string todoId)
|
||||
{
|
||||
return await Mediator.Send(new GetTodoByIdQuery(todoId));
|
||||
}
|
||||
=> await Mediator.Send(new GetTodoByIdQuery(todoId));
|
||||
|
||||
[HttpGet]
|
||||
public async Task<ActionResult<IEnumerable<TodoViewModel>>> GetTodos([FromQuery] bool onlyActive = false)
|
||||
@@ -80,7 +80,7 @@ public class TodosController : ApiController
|
||||
|
||||
[JsonPropertyName("created")]
|
||||
public long Created { get; init; } = 0;
|
||||
|
||||
|
||||
[JsonPropertyName("priority")]
|
||||
public string? Priority { get; init; }
|
||||
|
||||
|
@@ -42,7 +42,7 @@ public record CreateTodoCommand(
|
||||
request.TodoTitle,
|
||||
request.TodoProject,
|
||||
request.TodoDescription,
|
||||
request.Priority
|
||||
request.Priority,
|
||||
userId,
|
||||
DateTimeOffset.UtcNow.ToUnixTimeMilliseconds());
|
||||
|
||||
|
@@ -7,7 +7,8 @@ public record TodoViewModel(
|
||||
string AuthorId,
|
||||
string? Project,
|
||||
string? Description,
|
||||
long Created
|
||||
long Created,
|
||||
string? Priority
|
||||
)
|
||||
{
|
||||
internal static TodoViewModel From(Entities.Todo t) => new(
|
||||
@@ -17,5 +18,6 @@ public record TodoViewModel(
|
||||
t.AuthorId,
|
||||
t.Project,
|
||||
t.Description,
|
||||
t.Created);
|
||||
t.Created,
|
||||
t.Priority);
|
||||
}
|
@@ -21,6 +21,7 @@ public class TodoRepository : ITodoRepository
|
||||
string title,
|
||||
string? projectName,
|
||||
string? description,
|
||||
string? priority,
|
||||
string userId,
|
||||
long created)
|
||||
{
|
||||
@@ -31,7 +32,8 @@ public class TodoRepository : ITodoRepository
|
||||
Status = false,
|
||||
AuthorId = userId,
|
||||
Description = description,
|
||||
Created = created
|
||||
Created = created,
|
||||
Priority = priority
|
||||
};
|
||||
await _todosCollection.InsertOneAsync(todo);
|
||||
return todo.To();
|
||||
@@ -77,7 +79,8 @@ public class TodoRepository : ITodoRepository
|
||||
ProjectName = todo.Project,
|
||||
AuthorId = todo.AuthorId,
|
||||
Description = todo.Description,
|
||||
Created = todo.Created
|
||||
Created = todo.Created,
|
||||
Priority = todo.Priority
|
||||
});
|
||||
|
||||
return updatedTodo.To();
|
||||
|
Reference in New Issue
Block a user