Added Comments to the Controllers
This commit is contained in:
parent
faafbbeb62
commit
2cfdc85a90
|
@ -7,12 +7,19 @@ using Microsoft.EntityFrameworkCore;
|
|||
|
||||
namespace ScrumTaskboard.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// This is a controller of Categories class includes all API's related to the Categories.
|
||||
/// </summary>
|
||||
[Route("[controller]")]
|
||||
[ApiController]
|
||||
public class CategoriesController : ControllerBase
|
||||
{
|
||||
private readonly TaskContext _context;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the class.
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
public CategoriesController(TaskContext context)
|
||||
{
|
||||
_context = context;
|
||||
|
@ -61,23 +68,23 @@ namespace ScrumTaskboard.Controllers
|
|||
[HttpPut("{id}")]
|
||||
public async Task<IActionResult> 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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Prüft, ob eine Kategorie mit der angegebenen ID bereits existiert.
|
||||
/// Checks whether a category with the specified ID already exists.
|
||||
/// </summary>
|
||||
private bool CategoryExists(int id)
|
||||
{
|
||||
|
|
|
@ -7,12 +7,19 @@ using Microsoft.EntityFrameworkCore;
|
|||
|
||||
namespace ScrumTaskboard.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// This is a controller of Projects class includes all API's related to the Projects.
|
||||
/// </summary>
|
||||
[Route("[controller]")]
|
||||
[ApiController]
|
||||
public class ProjectsController : ControllerBase
|
||||
{
|
||||
private readonly TaskContext _context;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the class.
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
public ProjectsController(TaskContext context)
|
||||
{
|
||||
_context = context;
|
||||
|
@ -56,23 +63,23 @@ namespace ScrumTaskboard.Controllers
|
|||
[HttpPut("{id}")]
|
||||
public async Task<IActionResult> 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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Prüft, ob ein Project mit der angegebenen ID bereits existiert.
|
||||
/// Checks whether a project with the specified ID already exists.
|
||||
/// </summary>
|
||||
private bool ProjectExists(int id)
|
||||
{
|
||||
|
|
|
@ -7,12 +7,19 @@ using Microsoft.EntityFrameworkCore;
|
|||
|
||||
namespace ScrumTaskboard.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// This is a controller of Sprints class includes all API's related to the Sprints.
|
||||
/// </summary>
|
||||
[Route("[controller]")]
|
||||
[ApiController]
|
||||
public class SprintsController : ControllerBase
|
||||
{
|
||||
private readonly TaskContext _context;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the class.
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
public SprintsController(TaskContext context)
|
||||
{
|
||||
_context = context;
|
||||
|
@ -64,23 +71,23 @@ namespace ScrumTaskboard.Controllers
|
|||
[HttpPut("{id}")]
|
||||
public async Task<IActionResult> 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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Prüft, ob ein Sprint mit der angegebenen ID bereits existiert.
|
||||
/// Checks whether a sprint with the specified ID already exists.
|
||||
/// </summary>
|
||||
private bool SprintExists(int id)
|
||||
{
|
||||
|
|
|
@ -6,12 +6,19 @@ using Microsoft.EntityFrameworkCore;
|
|||
|
||||
namespace ScrumTaskboard.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// This is a controller of Status class includes all API's related to the Status.
|
||||
/// </summary>
|
||||
[Route("[controller]")]
|
||||
[ApiController]
|
||||
public class StatusController : ControllerBase
|
||||
{
|
||||
private readonly TaskContext _context;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the class.
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
public StatusController(TaskContext context)
|
||||
{
|
||||
_context = context;
|
||||
|
@ -51,23 +58,23 @@ namespace ScrumTaskboard.Controllers
|
|||
[HttpPut("{id}")]
|
||||
public async Task<IActionResult> 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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Prüft, ob ein Status mit der angegebenen ID bereits existiert.
|
||||
/// Checks whether a status with the specified ID already exists.
|
||||
/// </summary>
|
||||
private bool StatusExists(int id)
|
||||
{
|
||||
|
|
|
@ -7,12 +7,19 @@ using Microsoft.EntityFrameworkCore;
|
|||
|
||||
namespace ScrumTaskboard.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// This is a controller of Tasks class includes all API's related to the Tasks.
|
||||
/// </summary>
|
||||
[Route("[controller]")]
|
||||
[ApiController]
|
||||
public class TasksController : ControllerBase
|
||||
{
|
||||
private readonly TaskContext _context;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the class.
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
public TasksController(TaskContext context)
|
||||
{
|
||||
_context = context;
|
||||
|
@ -73,23 +80,23 @@ namespace ScrumTaskboard.Controllers
|
|||
[HttpPut("{id}")]
|
||||
public async Task<IActionResult> 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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Prüft, ob ein Task mit der angegebenen ID bereits existiert.
|
||||
/// Checks whether a task with the specified ID already exists.
|
||||
/// </summary>
|
||||
private bool TaskExists(int id)
|
||||
{
|
||||
|
|
|
@ -6,12 +6,19 @@ using Microsoft.EntityFrameworkCore;
|
|||
|
||||
namespace ScrumTaskboard.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// This is a controller of Users class includes all API's related to the Users.
|
||||
/// </summary>
|
||||
[Route("[controller]")]
|
||||
[ApiController]
|
||||
public class UsersController : ControllerBase
|
||||
{
|
||||
private readonly TaskContext _context;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the class.
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
public UsersController(TaskContext context)
|
||||
{
|
||||
_context = context;
|
||||
|
@ -50,23 +57,23 @@ namespace ScrumTaskboard.Controllers
|
|||
[HttpPut("{id}")]
|
||||
public async Task<IActionResult> 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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Prüft, ob ein User mit der angegebenen ID bereits existiert.
|
||||
/// Checks whether a user with the specified ID already exists.
|
||||
/// </summary>
|
||||
private bool UserExists(int id)
|
||||
{
|
||||
|
|
|
@ -7,12 +7,19 @@ using Microsoft.EntityFrameworkCore;
|
|||
|
||||
namespace ScrumTaskboard.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// This is a controller of Userstories class includes all API's related to the Userstories.
|
||||
/// </summary>
|
||||
[Route("[controller]")]
|
||||
[ApiController]
|
||||
public class UserstoriesController : ControllerBase
|
||||
{
|
||||
private readonly TaskContext _context;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the class.
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
public UserstoriesController(TaskContext context)
|
||||
{
|
||||
_context = context;
|
||||
|
@ -77,23 +84,23 @@ namespace ScrumTaskboard.Controllers
|
|||
[HttpPut("{id}")]
|
||||
public async Task<IActionResult> 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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Prüft, ob eine Userstory mit der angegebenen ID bereits existiert.
|
||||
/// Checks whether a userstory with the specified ID already exists.
|
||||
/// </summary>
|
||||
private bool UserstoryExists(int id)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue