srumboard_backend/ScrumTaskboard/TaskContext.cs

181 lines
5.4 KiB
C#

using Microsoft.EntityFrameworkCore;
using System;
using System.Runtime.Serialization;
namespace ScrumTaskboard
{
/// <summary>
/// Provides access to the database via the Entity Framework Core.
/// </summary>
/// <remarks>
/// Each <see cref="DbSet{TEntity}"/> property represents a table.
/// Tables can be queried and updated via the context class.
/// </remarks>
public class TaskContext : DbContext
{
public DbSet<ScrumTask> Tasks { get; set; }
public DbSet<ScrumUserstory> Userstories { get; set; }
public DbSet<ScrumCategory> Categories { get; set; }
public DbSet<ScrumSprint> Sprints { get; set; }
public DbSet<ScrumStatus> Status { get; set; }
public DbSet<ScrumProject> Projects { get; set; }
public DbSet<ScrumUser> Users { get; set; }
/// <summary>
/// Creates a new <see cref="TaskContext"/> instance with default options.
/// </summary>
public TaskContext() { }
/// <summary>
/// Creates a new <see cref="TaskContext"/> instance with the given options.
/// </summary>
public TaskContext(DbContextOptions<TaskContext> options) : base(options) { }
}
/// <summary>
/// Represents a task in an agile work process.
/// </summary>
/// <remarks>
/// A task is a small piece of work, associated with a larger userstory.
/// </remarks>
public class ScrumTask
{
public int Id { get; set; }
public string Title { get; set; }
public string Content { get; set; }
public int? StatusId { get; set; }
public ScrumStatus Status { get; set; }
public int? AssignedToId { get; set; }
public ScrumUser AssignedTo { get; set; }
public int? ProjectId { get; set; }
public ScrumProject Project { get; set; }
public int? UserstoryId { get; set; }
public ScrumUserstory Userstory { get; set; }
public ScrumPrio Priority { get; set; }
}
/// <summary>
/// Represents a userstory in an agile work process.
/// </summary>
/// <remarks>
/// A userstory is a piece of work that can be done in one sprint.
/// It can be further divided into multiple tasks.
/// </remarks>
public class ScrumUserstory
{
public int Id { get; set; }
public string Title { get; set; }
public string Content { get; set; }
public ScrumPrio Priority { get; set; }
public int? StatusId { get; set; }
public ScrumStatus Status { get; set; }
public int? CategoryId { get; set; }
public ScrumCategory Category { get; set; }
public int? CreatedById { get; set; }
public ScrumUser CreatedBy { get; set; }
public int? ProjectId { get; set; }
public ScrumProject Project { get; set; }
public int? SprintId { get; set; }
public ScrumSprint Sprint { get; set; }
}
/// <summary>
/// Represents a category of userstories.
/// </summary>
/// <remarks>
/// Every userstory can optionally be associated with a single category.
/// This can be helpful to organize work in larger teams.
/// </remarks>
public class ScrumCategory
{
public int Id { get; set; }
public string Title { get; set; }
public string Description { get; set; }
public string Color { get; set; }
public int? ProjectId { get; set; }
public ScrumProject Project { get; set; }
}
/// <summary>
/// Represents an agile sprint.
/// </summary>
/// <remarks>
/// A sprint is typically one to four weeks long.
/// Userstories are typically started and completed
/// during one sprint.
/// </remarks>
public class ScrumSprint
{
public int Id { get; set; }
public string Title { get; set; }
public string Description { get; set; }
public DateTime StartDate { get; set; }
public DateTime EndDate { get; set; }
public int? ProjectId { get; set; }
public ScrumProject Project { get; set; }
}
/// <summary>
/// Represents the status of a task or userstory.
/// </summary>
/// <remarks>
/// Classic status are "Backlog", "In Progress" and "Done", but
/// teams can create others to fit their individual workflow.
/// </remarks>
public class ScrumStatus
{
public int Id { get; set; }
public string Title { get; set; }
public string Description { get; set; }
}
/// <summary>
/// Represents a project that the team works on.
/// </summary>
/// <remarks>
/// Userstories and sprints can be categorized into projects,
/// to help organization for larger teams.
/// </remarks>
public class ScrumProject
{
public int Id { get; set; }
public string Title { get; set; }
public bool IsPrivate { get; set; }
}
/// <summary>
/// Represents a team member that can work on userstories.
/// </summary>
/// <remarks>
/// This allows teams to track who is working on a userstory
/// at a given time.
/// </remarks>
public class ScrumUser
{
public int Id { get; set; }
public string Name { get; set; }
}
public enum ScrumPrio
{
[EnumMember(Value = "low")]
Low,
[EnumMember(Value = "medium")]
Medium,
[EnumMember(Value = "high")]
High
}
}