diff --git a/ScrumTaskboard/Controllers/CategoriesController.cs b/ScrumTaskboard/Controllers/CategoriesController.cs index a78afd4..825d464 100644 --- a/ScrumTaskboard/Controllers/CategoriesController.cs +++ b/ScrumTaskboard/Controllers/CategoriesController.cs @@ -34,15 +34,15 @@ namespace ScrumTaskboard.Controllers if (title != null) { - filtered = filtered.Where(c => c.title.Contains(title)); + filtered = filtered.Where(c => c.Title.Contains(title)); } if (projectid != null) { - filtered = filtered.Where(c => c.projectid == projectid); + filtered = filtered.Where(c => c.ProjectId == projectid); } if (color != null) { - filtered = filtered.Where(c => c.color == color); + filtered = filtered.Where(c => c.Color == color); } @@ -132,7 +132,7 @@ namespace ScrumTaskboard.Controllers /// private bool CategoryExists(int id) { - return _context.Categories.Any(e => e.id == id); + return _context.Categories.Any(e => e.Id == id); } } } \ No newline at end of file diff --git a/ScrumTaskboard/Controllers/ProjectsController.cs b/ScrumTaskboard/Controllers/ProjectsController.cs index 8bbb6ab..2b97be8 100644 --- a/ScrumTaskboard/Controllers/ProjectsController.cs +++ b/ScrumTaskboard/Controllers/ProjectsController.cs @@ -34,11 +34,11 @@ namespace ScrumTaskboard.Controllers if (title != null) { - filtered = filtered.Where(t => t.title.Contains(title)); + filtered = filtered.Where(t => t.Title.Contains(title)); } if (isprivate != null) { - filtered = filtered.Where(t => t.isprivate == isprivate); + filtered = filtered.Where(t => t.IsPrivate == isprivate); } return await filtered.ToListAsync(); @@ -49,14 +49,14 @@ namespace ScrumTaskboard.Controllers [HttpGet("{id}")] public async Task> GetProjects(int id) { - var Project = await _context.Projects.FindAsync(id); + var project = await _context.Projects.FindAsync(id); - if (Project == null) + if (project == null) { return NotFound(); } - return Project; + return project; } // PUT: api/Project/5 @@ -127,7 +127,7 @@ namespace ScrumTaskboard.Controllers /// private bool ProjectExists(int id) { - return _context.Projects.Any(e => e.id == id); + return _context.Projects.Any(e => e.Id == id); } } } \ No newline at end of file diff --git a/ScrumTaskboard/Controllers/SprintsController.cs b/ScrumTaskboard/Controllers/SprintsController.cs index 0148e99..7ffbe12 100644 --- a/ScrumTaskboard/Controllers/SprintsController.cs +++ b/ScrumTaskboard/Controllers/SprintsController.cs @@ -1,55 +1,55 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Mvc; -using Microsoft.EntityFrameworkCore; - -namespace ScrumTaskboard.Controllers -{ +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; +using Microsoft.EntityFrameworkCore; + +namespace ScrumTaskboard.Controllers +{ /// /// This is a controller of Sprints class includes all API's related to the Sprints. - /// - [Route("[controller]")] - [ApiController] - public class SprintsController : ControllerBase - { - private readonly TaskContext _context; - + /// + [Route("[controller]")] + [ApiController] + public class SprintsController : ControllerBase + { + private readonly TaskContext _context; + /// /// Initializes a new instance of the class. /// - /// - public SprintsController(TaskContext context) - { - _context = context; + /// + public SprintsController(TaskContext context) + { + _context = context; } // GET: api/sprint - #nullable enable - [HttpGet] - public async Task>> GetSprint([FromQuery]string? title, [FromQuery]int? projectid, [FromQuery]DateTime? startDate, [FromQuery]DateTime? endDate) - { - var filtered = _context.Sprints.AsQueryable(); - - if (title != null) - { - filtered = filtered.Where(s => s.title.Contains(title)); - } - if (projectid != null) - { - filtered = filtered.Where(s => s.projectid == projectid); - } + #nullable enable + [HttpGet] + public async Task>> GetSprint([FromQuery]string? title, [FromQuery]int? projectid, [FromQuery]DateTime? startDate, [FromQuery]DateTime? endDate) + { + var filtered = _context.Sprints.AsQueryable(); + + if (title != null) + { + filtered = filtered.Where(s => s.Title.Contains(title)); + } + if (projectid != null) + { + filtered = filtered.Where(s => s.ProjectId == projectid); + } if (startDate != null) { - filtered = filtered.Where(s => s.startDate == startDate); + filtered = filtered.Where(s => s.StartDate == startDate); } if (endDate != null) - { - filtered = filtered.Where(s => s.endDate == endDate); - } - - return await filtered.ToListAsync(); + { + filtered = filtered.Where(s => s.EndDate == endDate); + } + + return await filtered.ToListAsync(); } #nullable disable @@ -57,14 +57,14 @@ namespace ScrumTaskboard.Controllers [HttpGet("{id}")] public async Task> GetSprint(int id) { - var Sprint = await _context.Sprints.FindAsync(id); + var sprint = await _context.Sprints.FindAsync(id); - if (Sprint == null) + if (sprint == null) { return NotFound(); } - return Sprint; + return sprint; } // PUT: api/sprint/5 @@ -130,12 +130,12 @@ namespace ScrumTaskboard.Controllers return scrumSprint; } - /// - /// Checks whether a sprint with the specified ID already exists. - /// + /// + /// Checks whether a sprint with the specified ID already exists. + /// private bool SprintExists(int id) { - return _context.Sprints.Any(e => e.id == id); + return _context.Sprints.Any(e => e.Id == id); } - } -} + } +} diff --git a/ScrumTaskboard/Controllers/StatusController.cs b/ScrumTaskboard/Controllers/StatusController.cs index 9b6bc32..1240770 100644 --- a/ScrumTaskboard/Controllers/StatusController.cs +++ b/ScrumTaskboard/Controllers/StatusController.cs @@ -33,7 +33,7 @@ namespace ScrumTaskboard.Controllers if (title != null) { - filtered = filtered.Where(s => s.title.Contains(title)); + filtered = filtered.Where(s => s.Title.Contains(title)); } return await filtered.ToListAsync(); @@ -122,7 +122,7 @@ namespace ScrumTaskboard.Controllers /// private bool StatusExists(int id) { - return _context.Status.Any(e => e.id == id); + return _context.Status.Any(e => e.Id == id); } } } \ No newline at end of file diff --git a/ScrumTaskboard/Controllers/TasksController.cs b/ScrumTaskboard/Controllers/TasksController.cs index aaa5397..69f595e 100644 --- a/ScrumTaskboard/Controllers/TasksController.cs +++ b/ScrumTaskboard/Controllers/TasksController.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; @@ -7,8 +7,8 @@ using Microsoft.EntityFrameworkCore; namespace ScrumTaskboard.Controllers { - /// - /// This is a controller of Tasks class includes all API's related to the Tasks. + /// + /// This is a controller of Tasks class includes all API's related to the Tasks. /// [Route("[controller]")] [ApiController] @@ -16,53 +16,53 @@ namespace ScrumTaskboard.Controllers { private readonly TaskContext _context; - /// - /// Initializes a new instance of the class. - /// + /// + /// Initializes a new instance of the class. + /// /// public TasksController(TaskContext context) { _context = context; - } - - // GET: api/tasks + } + + // GET: api/tasks #nullable enable [HttpGet] public async Task>> GetTasks([FromQuery]string? title, [FromQuery]int? userstoryid, [FromQuery]int? statusid, [FromQuery]int? assignedtoid, [FromQuery]int? projectid, [FromQuery]ScrumPrio? priority) { var filtered = _context.Tasks.AsQueryable(); - if (title != null) - { - filtered = filtered.Where(t => t.title.Contains(title)); + if (title != null) + { + filtered = filtered.Where(t => t.Title.Contains(title)); } - if (userstoryid != null) - { - filtered = filtered.Where(t => t.userstoryid == userstoryid); + if (userstoryid != null) + { + filtered = filtered.Where(t => t.UserstoryId == userstoryid); } - if (statusid != null) - { - filtered = filtered.Where(t => t.statusid == statusid); + if (statusid != null) + { + filtered = filtered.Where(t => t.StatusId == statusid); } - if (assignedtoid != null) - { - filtered = filtered.Where(t => t.assignedtoid == assignedtoid); + if (assignedtoid != null) + { + filtered = filtered.Where(t => t.AssignedToId == assignedtoid); } - if (projectid != null) - { - filtered = filtered.Where(t => t.projectid == projectid); + if (projectid != null) + { + filtered = filtered.Where(t => t.ProjectId == projectid); } - if (priority != null) - { - filtered = filtered.Where(t => t.priority == priority); - } - - + if (priority != null) + { + filtered = filtered.Where(t => t.Priority == priority); + } + + return await filtered.ToListAsync(); - } + } #nullable disable - - // GET: api/tasks/5 + + // GET: api/tasks/5 [HttpGet("{id}")] public async Task> GetTask(int id) { @@ -144,7 +144,7 @@ namespace ScrumTaskboard.Controllers /// private bool TaskExists(int id) { - return _context.Tasks.Any(e => e.id == id); + return _context.Tasks.Any(e => e.Id == id); } } } diff --git a/ScrumTaskboard/Controllers/UsersController.cs b/ScrumTaskboard/Controllers/UsersController.cs index df0b00d..0d1eaf8 100644 --- a/ScrumTaskboard/Controllers/UsersController.cs +++ b/ScrumTaskboard/Controllers/UsersController.cs @@ -32,7 +32,7 @@ namespace ScrumTaskboard.Controllers var filtered = _context.Users.AsQueryable(); if (name != null) { - filtered = filtered.Where(u => u.name.Contains(name)); + filtered = filtered.Where(u => u.Name.Contains(name)); } return await filtered.ToListAsync(); @@ -43,14 +43,14 @@ namespace ScrumTaskboard.Controllers [HttpGet("{id}")] public async Task> GetUser(int id) { - var User = await _context.Users.FindAsync(id); + var user = await _context.Users.FindAsync(id); - if (User == null) + if (user == null) { return NotFound(); } - return User; + return user; } // PUT: api/sprint/5 @@ -121,7 +121,7 @@ namespace ScrumTaskboard.Controllers /// private bool UserExists(int id) { - return _context.Users.Any(e => e.id == id); + return _context.Users.Any(e => e.Id == id); } } } \ No newline at end of file diff --git a/ScrumTaskboard/Controllers/UserstoriesController.cs b/ScrumTaskboard/Controllers/UserstoriesController.cs index 498fb12..dd59557 100644 --- a/ScrumTaskboard/Controllers/UserstoriesController.cs +++ b/ScrumTaskboard/Controllers/UserstoriesController.cs @@ -34,31 +34,31 @@ namespace ScrumTaskboard.Controllers if (title != null) { - filtered = filtered.Where(t => t.title.Contains(title)); + filtered = filtered.Where(t => t.Title.Contains(title)); } if (statusid != null) { - filtered = filtered.Where(t => t.statusid == statusid); + filtered = filtered.Where(t => t.StatusId == statusid); } if (categoryid != null) { - filtered = filtered.Where(t => t.categoryid == categoryid); + filtered = filtered.Where(t => t.CategoryId == categoryid); } if (createdbyid != null) { - filtered = filtered.Where(t => t.createdbyid == createdbyid); + filtered = filtered.Where(t => t.CreatedById == createdbyid); } if (projectid != null) { - filtered = filtered.Where(t => t.projectid == projectid); + filtered = filtered.Where(t => t.ProjectId == projectid); } if (sprintid != null) { - filtered = filtered.Where(t => t.sprintid == sprintid); + filtered = filtered.Where(t => t.SprintId == sprintid); } if (priority != null) { - filtered = filtered.Where(t => t.priority == priority); + filtered = filtered.Where(t => t.Priority == priority); } @@ -148,7 +148,7 @@ namespace ScrumTaskboard.Controllers /// private bool UserstoryExists(int id) { - return _context.Userstories.Any(e => e.id == id); + return _context.Userstories.Any(e => e.Id == id); } } } \ No newline at end of file diff --git a/ScrumTaskboard/TaskContext.cs b/ScrumTaskboard/TaskContext.cs index 973f4e2..8e5fa43 100644 --- a/ScrumTaskboard/TaskContext.cs +++ b/ScrumTaskboard/TaskContext.cs @@ -4,6 +4,13 @@ using System.Runtime.Serialization; namespace ScrumTaskboard { + /// + /// Provides access to the database via the Entity Framework Core. + /// + /// + /// Each property represents a table. + /// Tables can be queried and updated via the context class. + /// public class TaskContext : DbContext { public DbSet Tasks { get; set; } @@ -14,106 +21,160 @@ namespace ScrumTaskboard public DbSet Projects { get; set; } public DbSet Users { get; set; } + /// + /// Creates a new instance with default options. + /// public TaskContext() { } + /// + /// Creates a new instance with the given options. + /// public TaskContext(DbContextOptions options) : base(options) { } } + /// + /// Represents a task in an agile work process. + /// + /// + /// A task is a small piece of work, associated with a larger userstory. + /// public class ScrumTask { - public int id { get; set; } - public string title { get; set; } - public string content { get; set; } + 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? StatusId { get; set; } + public ScrumStatus Status { get; set; } - public int? assignedtoid { get; set; } - public ScrumUser assignedto { get; set; } + public int? AssignedToId { get; set; } + public ScrumUser AssignedTo { get; set; } - public int? projectid { get; set; } - public ScrumProject project { get; set; } + public int? ProjectId { get; set; } + public ScrumProject Project { get; set; } - public int? userstoryid { get; set; } - public ScrumUserstory userstory { get; set; } + public int? UserstoryId { get; set; } + public ScrumUserstory Userstory { get; set; } - public ScrumPrio priority { get; set; } + public ScrumPrio Priority { get; set; } } + /// + /// Represents a userstory in an agile work process. + /// + /// + /// A userstory is a piece of work that can be done in one sprint. + /// It can be further divided into multiple tasks. + /// 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 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? StatusId { get; set; } + public ScrumStatus Status { get; set; } - public int? categoryid { get; set; } - public ScrumCategory category { get; set; } + public int? CategoryId { get; set; } + public ScrumCategory Category { get; set; } - public int? createdbyid { get; set; } - public ScrumUser createdby { get; set; } + public int? CreatedById { get; set; } + public ScrumUser CreatedBy { get; set; } - public int? projectid { get; set; } - public ScrumProject project { get; set; } + public int? ProjectId { get; set; } + public ScrumProject Project { get; set; } - public int? sprintid { get; set; } - public ScrumSprint sprint { get; set; } + public int? SprintId { get; set; } + public ScrumSprint Sprint { get; set; } } + /// + /// Represents a category of userstories. + /// + /// + /// Every userstory can optionally be associated with a single category. + /// This can be helpful to organize work in larger teams. + /// 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 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; } + public int? ProjectId { get; set; } + public ScrumProject Project { get; set; } } + /// + /// Represents an agile sprint. + /// + /// + /// A sprint is typically one to four weeks long. + /// Userstories are typically started and completed + /// during one sprint. + /// 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 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; } + public int? ProjectId { get; set; } + public ScrumProject Project { get; set; } } + /// + /// Represents the status of a task or userstory. + /// + /// + /// Classic status are "Backlog", "In Progress" and "Done", but + /// teams can create others to fit their individual workflow. + /// public class ScrumStatus { - public int id { get; set; } - public string title { get; set; } - public string description { get; set; } + public int Id { get; set; } + public string Title { get; set; } + public string Description { get; set; } } + /// + /// Represents a project that the team works on. + /// + /// + /// Userstories and sprints can be categorized into projects, + /// to help organization for larger teams. + /// public class ScrumProject { - public int id { get; set; } - public string title { get; set; } - public bool isprivate { get; set; } + public int Id { get; set; } + public string Title { get; set; } + public bool IsPrivate { get; set; } } + /// + /// Represents a team member that can work on userstories. + /// + /// + /// This allows teams to track who is working on a userstory + /// at a given time. + /// public class ScrumUser { - public int id { get; set; } - public string name { get; set; } + public int Id { get; set; } + public string Name { get; set; } } public enum ScrumPrio { [EnumMember(Value = "low")] - low, + Low, [EnumMember(Value = "medium")] - medium, + Medium, [EnumMember(Value = "high")] - high + High } }