-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add models for basic to-do list management
- Loading branch information
1 parent
48d0480
commit c82ed0c
Showing
12 changed files
with
602 additions
and
43 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
using System.ComponentModel.DataAnnotations; | ||
using System.ComponentModel.DataAnnotations.Schema; | ||
|
||
namespace AdvancedTodoList.Core.Models.TodoLists; | ||
|
||
/// <summary> | ||
/// Represents a to-do list item entity. | ||
/// </summary> | ||
public class TodoItem | ||
{ | ||
/// <summary> | ||
/// An unique identifier for the to-do list item. | ||
/// </summary> | ||
[Key] | ||
public int Id { get; set; } | ||
/// <summary> | ||
/// Name (title) of the to-do item. | ||
/// </summary> | ||
[MaxLength(NameMaxLength)] | ||
public string Name { get; set; } = null!; | ||
/// <summary> | ||
/// Description of the to-do item. | ||
/// </summary> | ||
[MaxLength(DescriptionMaxLength)] | ||
public string Description { get; set; } = null!; | ||
/// <summary> | ||
/// Current state of the to-do item. | ||
/// </summary> | ||
public TodoItemState State { get; set; } | ||
/// <summary> | ||
/// Deadline date for the todo item. Can be null. | ||
/// </summary> | ||
public DateTime? DeadlineDate { get; set; } | ||
|
||
/// <summary> | ||
/// Foreign key referencing the associated to-do list. | ||
/// </summary> | ||
[ForeignKey(nameof(TodoList))] | ||
public string TodoListId { get; set; } = null!; | ||
|
||
/// <summary> | ||
/// Maximum allowed length of <see cref="Name"/>. | ||
/// </summary> | ||
public const int NameMaxLength = 100; | ||
/// <summary> | ||
/// Maximum allowed length of <see cref="Description"/>. | ||
/// </summary> | ||
public const int DescriptionMaxLength = 10_000; | ||
|
||
/// <summary> | ||
/// To-do list associated with this to-do item. | ||
/// </summary> | ||
public TodoList TodoList { get; set; } = null!; | ||
} | ||
|
||
/// <summary> | ||
/// An enum that represents the possible states of a to-do list item. | ||
/// </summary> | ||
public enum TodoItemState : byte | ||
{ | ||
/// <summary> | ||
/// The task is active (default state). | ||
/// </summary> | ||
Active = 0, | ||
/// <summary> | ||
/// The task has been completed. | ||
/// </summary> | ||
Completed, | ||
/// <summary> | ||
/// The task has been skipped. | ||
/// </summary> | ||
Skipped | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using System.ComponentModel.DataAnnotations; | ||
using System.ComponentModel.DataAnnotations.Schema; | ||
|
||
namespace AdvancedTodoList.Core.Models.TodoLists; | ||
|
||
/// <summary> | ||
/// Represents a to-do list entity. | ||
/// </summary> | ||
public class TodoList | ||
{ | ||
/// <summary> | ||
/// An unique identifier for the to-do list. | ||
/// </summary> | ||
[Key] | ||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)] | ||
public string Id { get; set; } = null!; | ||
|
||
/// <summary> | ||
/// Name (title) of the to-do list. | ||
/// </summary> | ||
[MaxLength(NameMaxLength)] | ||
public string Name { get; set; } = null!; | ||
/// <summary> | ||
/// Description of the to-do list. | ||
/// </summary> | ||
[MaxLength(DescriptionMaxLength)] | ||
public string Description { get; set; } = null!; | ||
|
||
/// <summary> | ||
/// Maximum allowed length of <see cref="Name"/>. | ||
/// </summary> | ||
public const int NameMaxLength = 100; | ||
/// <summary> | ||
/// Maximum allowed length of <see cref="Description"/>. | ||
/// </summary> | ||
public const int DescriptionMaxLength = 25_000; | ||
|
||
/// <summary> | ||
/// Collection of to-do items associated with this todo list. | ||
/// </summary> | ||
public virtual IEnumerable<TodoItem> TodoItems { get; set; } = null!; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.