From 2cfdc85a90945cc22f36c0ce25e54fd86f6430f7 Mon Sep 17 00:00:00 2001
From: Taha FADL <24903274+Taha5492@users.noreply.github.com>
Date: Wed, 8 Jul 2020 13:42:42 +0200
Subject: [PATCH] Added Comments to the Controllers
---
.../Controllers/CategoriesController.cs | 23 ++++++++++++-------
.../Controllers/ProjectsController.cs | 23 ++++++++++++-------
.../Controllers/SprintsController.cs | 23 ++++++++++++-------
.../Controllers/StatusController.cs | 23 ++++++++++++-------
ScrumTaskboard/Controllers/TasksController.cs | 23 ++++++++++++-------
ScrumTaskboard/Controllers/UsersController.cs | 23 ++++++++++++-------
.../Controllers/UserstoriesController.cs | 23 ++++++++++++-------
7 files changed, 105 insertions(+), 56 deletions(-)
diff --git a/ScrumTaskboard/Controllers/CategoriesController.cs b/ScrumTaskboard/Controllers/CategoriesController.cs
index f2b3a6d..a78afd4 100644
--- a/ScrumTaskboard/Controllers/CategoriesController.cs
+++ b/ScrumTaskboard/Controllers/CategoriesController.cs
@@ -7,12 +7,19 @@ using Microsoft.EntityFrameworkCore;
namespace ScrumTaskboard.Controllers
{
+ ///
+ /// This is a controller of Categories class includes all API's related to the Categories.
+ ///
[Route("[controller]")]
[ApiController]
public class CategoriesController : ControllerBase
{
private readonly TaskContext _context;
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ ///
public CategoriesController(TaskContext context)
{
_context = context;
@@ -61,23 +68,23 @@ namespace ScrumTaskboard.Controllers
[HttpPut("{id}")]
public async Task PutCategory(int id, ScrumCategory category)
{
- // Die ID der Kategorie darf nicht geändert werden
+ // The category's ID must not be changed
if (id != category.id)
{
return BadRequest();
}
- // Speichere die geänderten Kategorie im Context
+ // Save the changed category in the context
_context.Entry(category).State = EntityState.Modified;
try
{
- // Übernehme die Änderungen in die Datenbank
+ // Apply the changes to the database
await _context.SaveChangesAsync();
}
catch (DbUpdateConcurrencyException)
{
- // Wenn die Kategorie nicht existiert, gib Statuscode 404 zurück
+ // If the category does not exist, return status code 404
if (!CategoryExists(id))
{
return NotFound();
@@ -98,7 +105,7 @@ namespace ScrumTaskboard.Controllers
_context.Categories.Add(category);
await _context.SaveChangesAsync();
- // Die neue Userstory wurde erstellt und kann über die GetUserstory Methode abgerufen werden.
+ // The new user story has been created and can be called up using the GetUserstory method
return CreatedAtAction("GetCategory", new { id = category.id }, category);
}
@@ -112,16 +119,16 @@ namespace ScrumTaskboard.Controllers
return NotFound();
}
- // Entferne die Kateorie aus dem Context
+ // Remove the category from the context
_context.Categories.Remove(category);
- // Speichere die Änderungen in der Datenbank
+ // Save the changes in the database
await _context.SaveChangesAsync();
return category;
}
///
- /// Prüft, ob eine Kategorie mit der angegebenen ID bereits existiert.
+ /// Checks whether a category with the specified ID already exists.
///
private bool CategoryExists(int id)
{
diff --git a/ScrumTaskboard/Controllers/ProjectsController.cs b/ScrumTaskboard/Controllers/ProjectsController.cs
index e78521f..8bbb6ab 100644
--- a/ScrumTaskboard/Controllers/ProjectsController.cs
+++ b/ScrumTaskboard/Controllers/ProjectsController.cs
@@ -7,12 +7,19 @@ using Microsoft.EntityFrameworkCore;
namespace ScrumTaskboard.Controllers
{
+ ///
+ /// This is a controller of Projects class includes all API's related to the Projects.
+ ///
[Route("[controller]")]
[ApiController]
public class ProjectsController : ControllerBase
{
private readonly TaskContext _context;
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ ///
public ProjectsController(TaskContext context)
{
_context = context;
@@ -56,23 +63,23 @@ namespace ScrumTaskboard.Controllers
[HttpPut("{id}")]
public async Task PutProject(int id, ScrumProject projects)
{
- // Die ID des Projects darf nicht geändert werden
+ // The project's ID must not be changed
if (id != projects.id)
{
return BadRequest();
}
- // Speichere den geänderten Project im Context
+ // Save the changed project in the context
_context.Entry(projects).State = EntityState.Modified;
try
{
- // Übernehme die Änderungen in die Datenbank
+ // Apply the changes to the database
await _context.SaveChangesAsync();
}
catch (DbUpdateConcurrencyException)
{
- // Wenn der Project nicht existiert, gib Statuscode 404 zurück
+ // If the project does not exist, return status code 404
if (!ProjectExists(id))
{
return NotFound();
@@ -93,7 +100,7 @@ namespace ScrumTaskboard.Controllers
_context.Projects.Add(projects);
await _context.SaveChangesAsync();
- // Der neue Project wurde erstellt und kann über die GetProject Methode abgerufen werden.
+ // The new project has been created and can be called up using the GetProject method
return CreatedAtAction("GetProject", new { id = projects.id }, projects);
}
@@ -107,16 +114,16 @@ namespace ScrumTaskboard.Controllers
return NotFound();
}
- // Entferne den Project aus dem Context
+ // Remove the project from the context
_context.Projects.Remove(scrumProject);
- // Speichere die Änderungen in der Datenbank
+ // Save the changes in the database
await _context.SaveChangesAsync();
return scrumProject;
}
///
- /// Prüft, ob ein Project mit der angegebenen ID bereits existiert.
+ /// Checks whether a project with the specified ID already exists.
///
private bool ProjectExists(int id)
{
diff --git a/ScrumTaskboard/Controllers/SprintsController.cs b/ScrumTaskboard/Controllers/SprintsController.cs
index 185cdd2..0148e99 100644
--- a/ScrumTaskboard/Controllers/SprintsController.cs
+++ b/ScrumTaskboard/Controllers/SprintsController.cs
@@ -7,12 +7,19 @@ 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;
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ ///
public SprintsController(TaskContext context)
{
_context = context;
@@ -64,23 +71,23 @@ namespace ScrumTaskboard.Controllers
[HttpPut("{id}")]
public async Task PutSprint(int id, ScrumSprint sprint)
{
- // Die ID des Sprints darf nicht geändert werden
+ // The sprint's ID must not be changed
if (id != sprint.id)
{
return BadRequest();
}
- // Speichere den geänderten Sprint im Context
+ // Save the changed sprint in the context
_context.Entry(sprint).State = EntityState.Modified;
try
{
- // Übernehme die Änderungen in die Datenbank
+ // Apply the changes to the database
await _context.SaveChangesAsync();
}
catch (DbUpdateConcurrencyException)
{
- // Wenn der Sprint nicht existiert, gib Statuscode 404 zurück
+ // If the sprint does not exist, return status code 404
if (!SprintExists(id))
{
return NotFound();
@@ -101,7 +108,7 @@ namespace ScrumTaskboard.Controllers
_context.Sprints.Add(sprint);
await _context.SaveChangesAsync();
- // Der neue Sprint wurde erstellt und kann über die GetSprint Methode abgerufen werden.
+ // The new sprint has been created and can be called up using the GetSprint method
return CreatedAtAction("GetSprint", new { id = sprint.id }, sprint);
}
@@ -115,16 +122,16 @@ namespace ScrumTaskboard.Controllers
return NotFound();
}
- // Entferne den Sprint aus dem Context
+ // Remove the sprint from the context
_context.Sprints.Remove(scrumSprint);
- // Speichere die Änderungen in der Datenbank
+ // Save the changes in the database
await _context.SaveChangesAsync();
return scrumSprint;
}
///
- /// Prüft, ob ein Sprint mit der angegebenen ID bereits existiert.
+ /// Checks whether a sprint with the specified ID already exists.
///
private bool SprintExists(int id)
{
diff --git a/ScrumTaskboard/Controllers/StatusController.cs b/ScrumTaskboard/Controllers/StatusController.cs
index 3532df9..9b6bc32 100644
--- a/ScrumTaskboard/Controllers/StatusController.cs
+++ b/ScrumTaskboard/Controllers/StatusController.cs
@@ -6,12 +6,19 @@ using Microsoft.EntityFrameworkCore;
namespace ScrumTaskboard.Controllers
{
+ ///
+ /// This is a controller of Status class includes all API's related to the Status.
+ ///
[Route("[controller]")]
[ApiController]
public class StatusController : ControllerBase
{
private readonly TaskContext _context;
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ ///
public StatusController(TaskContext context)
{
_context = context;
@@ -51,23 +58,23 @@ namespace ScrumTaskboard.Controllers
[HttpPut("{id}")]
public async Task PutStatus(int id, ScrumStatus userstory)
{
- // Die ID des Status darf nicht geändert werden
+ // The status' ID must not be changed
if (id != userstory.id)
{
return BadRequest();
}
- // Speichere deb geänderten Status im Context
+ // Save the changed status in the context
_context.Entry(userstory).State = EntityState.Modified;
try
{
- // Übernehme die Änderungen in die Datenbank
+ // Apply the changes to the database
await _context.SaveChangesAsync();
}
catch (DbUpdateConcurrencyException)
{
- // Wenn der Status nicht existiert, gib Statuscode 404 zurück
+ // If the status does not exist, return status code 404
if (!StatusExists(id))
{
return NotFound();
@@ -88,7 +95,7 @@ namespace ScrumTaskboard.Controllers
_context.Status.Add(userstory);
await _context.SaveChangesAsync();
- // Der neue Status wurde erstellt und kann über die GetStatus Methode abgerufen werden.
+ // The new status has been created and can be called up using the GetStatus method
return CreatedAtAction("GetStatus", new { id = userstory.id }, userstory);
}
@@ -102,16 +109,16 @@ namespace ScrumTaskboard.Controllers
return NotFound();
}
- // Entferne den Status aus dem Context
+ // Remove the status from the context
_context.Status.Remove(userstory);
- // Speichere die Änderungen in der Datenbank
+ // Save the changes in the database
await _context.SaveChangesAsync();
return userstory;
}
///
- /// Prüft, ob ein Status mit der angegebenen ID bereits existiert.
+ /// Checks whether a status with the specified ID already exists.
///
private bool StatusExists(int id)
{
diff --git a/ScrumTaskboard/Controllers/TasksController.cs b/ScrumTaskboard/Controllers/TasksController.cs
index c6dcdd1..aaa5397 100644
--- a/ScrumTaskboard/Controllers/TasksController.cs
+++ b/ScrumTaskboard/Controllers/TasksController.cs
@@ -7,12 +7,19 @@ using Microsoft.EntityFrameworkCore;
namespace ScrumTaskboard.Controllers
{
+ ///
+ /// This is a controller of Tasks class includes all API's related to the Tasks.
+ ///
[Route("[controller]")]
[ApiController]
public class TasksController : ControllerBase
{
private readonly TaskContext _context;
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ ///
public TasksController(TaskContext context)
{
_context = context;
@@ -73,23 +80,23 @@ namespace ScrumTaskboard.Controllers
[HttpPut("{id}")]
public async Task PutTask(int id, ScrumTask task)
{
- // Die ID des Tasks darf nicht geändert werden
+ // The task's ID must not be changed
if (id != task.id)
{
return BadRequest();
}
- // Speichere den geänderten Task im Context
+ // Save the changed task in the context
_context.Entry(task).State = EntityState.Modified;
try
{
- // Übernehme die Änderungen in die Datenbank
+ // Apply the changes to the database
await _context.SaveChangesAsync();
}
catch (DbUpdateConcurrencyException)
{
- // Wenn der Task nicht existiert, gib Statuscode 404 zurück
+ // If the task does not exist, return status code 404
if (!TaskExists(id))
{
return NotFound();
@@ -110,7 +117,7 @@ namespace ScrumTaskboard.Controllers
_context.Tasks.Add(task);
await _context.SaveChangesAsync();
- // Der neue Task wurde erstellt und kann über die GetTask Methode abgerufen werden.
+ // The new task has been created and can be called up using the GetTask method
return CreatedAtAction("GetTask", new { id = task.id }, task);
}
@@ -124,16 +131,16 @@ namespace ScrumTaskboard.Controllers
return NotFound();
}
- // Entferne den Task aus dem Context
+ // Remove the task from the context
_context.Tasks.Remove(scrumTask);
- // Speichere die Änderungen in der Datenbank
+ // Save the changes in the database
await _context.SaveChangesAsync();
return scrumTask;
}
///
- /// Prüft, ob ein Task mit der angegebenen ID bereits existiert.
+ /// Checks whether a task with the specified ID already exists.
///
private bool TaskExists(int id)
{
diff --git a/ScrumTaskboard/Controllers/UsersController.cs b/ScrumTaskboard/Controllers/UsersController.cs
index f0fe5c2..df0b00d 100644
--- a/ScrumTaskboard/Controllers/UsersController.cs
+++ b/ScrumTaskboard/Controllers/UsersController.cs
@@ -6,12 +6,19 @@ using Microsoft.EntityFrameworkCore;
namespace ScrumTaskboard.Controllers
{
+ ///
+ /// This is a controller of Users class includes all API's related to the Users.
+ ///
[Route("[controller]")]
[ApiController]
public class UsersController : ControllerBase
{
private readonly TaskContext _context;
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ ///
public UsersController(TaskContext context)
{
_context = context;
@@ -50,23 +57,23 @@ namespace ScrumTaskboard.Controllers
[HttpPut("{id}")]
public async Task PutUser(int id, ScrumUser sprint)
{
- // Die ID des Users darf nicht geändert werden
+ // The user's ID must not be changed
if (id != sprint.id)
{
return BadRequest();
}
- // Speichere den geänderten User im Context
+ // Save the changed user in the context
_context.Entry(sprint).State = EntityState.Modified;
try
{
- // Übernehme die Änderungen in die Datenbank
+ // Apply the changes to the database
await _context.SaveChangesAsync();
}
catch (DbUpdateConcurrencyException)
{
- // Wenn der User nicht existiert, gib Statuscode 404 zurück
+ // If the user does not exist, return status code 404
if (!UserExists(id))
{
return NotFound();
@@ -87,7 +94,7 @@ namespace ScrumTaskboard.Controllers
_context.Users.Add(sprint);
await _context.SaveChangesAsync();
- // Der neue User wurde erstellt und kann über die GetUser Methode abgerufen werden.
+ // The new user has been created and can be called up using the GetUser method
return CreatedAtAction("GetUser", new { id = sprint.id }, sprint);
}
@@ -101,16 +108,16 @@ namespace ScrumTaskboard.Controllers
return NotFound();
}
- // Entferne den User aus dem Context
+ // Remove the user from the context
_context.Users.Remove(scrumUser);
- // Speichere die Änderungen in der Datenbank
+ // Save the changes in the database
await _context.SaveChangesAsync();
return scrumUser;
}
///
- /// Prüft, ob ein User mit der angegebenen ID bereits existiert.
+ /// Checks whether a user with the specified ID already exists.
///
private bool UserExists(int id)
{
diff --git a/ScrumTaskboard/Controllers/UserstoriesController.cs b/ScrumTaskboard/Controllers/UserstoriesController.cs
index 605e247..498fb12 100644
--- a/ScrumTaskboard/Controllers/UserstoriesController.cs
+++ b/ScrumTaskboard/Controllers/UserstoriesController.cs
@@ -7,12 +7,19 @@ using Microsoft.EntityFrameworkCore;
namespace ScrumTaskboard.Controllers
{
+ ///
+ /// This is a controller of Userstories class includes all API's related to the Userstories.
+ ///
[Route("[controller]")]
[ApiController]
public class UserstoriesController : ControllerBase
{
private readonly TaskContext _context;
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ ///
public UserstoriesController(TaskContext context)
{
_context = context;
@@ -77,23 +84,23 @@ namespace ScrumTaskboard.Controllers
[HttpPut("{id}")]
public async Task PutUserstory(int id, ScrumUserstory userstory)
{
- // Die ID der Userstory darf nicht geändert werden
+ // The userstory's ID must not be changed
if (id != userstory.id)
{
return BadRequest();
}
- // Speichere die geänderten Userstory im Context
+ // Save the changed userstory in the context
_context.Entry(userstory).State = EntityState.Modified;
try
{
- // Übernehme die Änderungen in die Datenbank
+ // Apply the changes to the database
await _context.SaveChangesAsync();
}
catch (DbUpdateConcurrencyException)
{
- // Wenn die Userstory nicht existiert, gib Statuscode 404 zurück
+ // If the userstory does not exist, return status code 404
if (!UserstoryExists(id))
{
return NotFound();
@@ -114,7 +121,7 @@ namespace ScrumTaskboard.Controllers
_context.Userstories.Add(userstory);
await _context.SaveChangesAsync();
- // Die neue Userstory wurde erstellt und kann über die GetUserstory Methode abgerufen werden.
+ // The new userstory has been created and can be called up using the GetUserstory method
return CreatedAtAction("GetUserstory", new { id = userstory.id }, userstory);
}
@@ -128,16 +135,16 @@ namespace ScrumTaskboard.Controllers
return NotFound();
}
- // Entferne die Userstory aus dem Context
+ // Remove the userstory from the context
_context.Userstories.Remove(userstory);
- // Speichere die Änderungen in der Datenbank
+ // Save the changes in the database
await _context.SaveChangesAsync();
return userstory;
}
///
- /// Prüft, ob eine Userstory mit der angegebenen ID bereits existiert.
+ /// Checks whether a userstory with the specified ID already exists.
///
private bool UserstoryExists(int id)
{