Merge branch 'master' into deployment/env-vars
This commit is contained in:
commit
319e643688
|
@ -0,0 +1,114 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace ScrumTaskboard.Controllers
|
||||
{
|
||||
[Route("[controller]")]
|
||||
[ApiController]
|
||||
public class CategoriesController : ControllerBase
|
||||
{
|
||||
private readonly TaskContext _context;
|
||||
|
||||
public CategoriesController(TaskContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
// GET: api/category
|
||||
[HttpGet]
|
||||
public async Task<ActionResult<IEnumerable<ScrumCategory>>> GetCategory()
|
||||
{
|
||||
return await _context.Categories.ToListAsync();
|
||||
}
|
||||
|
||||
// GET: api/category/1
|
||||
[HttpGet("{id}")]
|
||||
public async Task<ActionResult<ScrumCategory>> GetCategory(int id)
|
||||
{
|
||||
var category = await _context.Categories.FindAsync(id);
|
||||
|
||||
if (category == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return category;
|
||||
}
|
||||
|
||||
// PUT: api/category/1
|
||||
[HttpPut("{id}")]
|
||||
public async Task<IActionResult> PutCategory(int id, ScrumCategory category)
|
||||
{
|
||||
// Die ID der Kategorie darf nicht geändert werden
|
||||
if (id != category.id)
|
||||
{
|
||||
return BadRequest();
|
||||
}
|
||||
|
||||
// Speichere die geänderten Kategorie im Context
|
||||
_context.Entry(category).State = EntityState.Modified;
|
||||
|
||||
try
|
||||
{
|
||||
// Übernehme die Änderungen in die Datenbank
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
catch (DbUpdateConcurrencyException)
|
||||
{
|
||||
// Wenn die Kategorie nicht existiert, gib Statuscode 404 zurück
|
||||
if (!CategoryExists(id))
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
return NoContent();
|
||||
}
|
||||
|
||||
// POST: api/category
|
||||
[HttpPost]
|
||||
public async Task<ActionResult<ScrumUserstory>> PostCategory(ScrumCategory category)
|
||||
{
|
||||
_context.Categories.Add(category);
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
// Die neue Userstory wurde erstellt und kann über die GetUserstory Methode abgerufen werden.
|
||||
return CreatedAtAction("GetCategory", new { id = category.id }, category);
|
||||
}
|
||||
|
||||
// DELETE: api/category/1
|
||||
[HttpDelete("{id}")]
|
||||
public async Task<ActionResult<ScrumCategory>> DeleteCategory(int id)
|
||||
{
|
||||
var category = await _context.Categories.FindAsync(id);
|
||||
if (category == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
// Entferne die Kateorie aus dem Context
|
||||
_context.Categories.Remove(category);
|
||||
// Speichere die Änderungen in der Datenbank
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
return category;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Prüft, ob eine Kategorie mit der angegebenen ID bereits existiert.
|
||||
/// </summary>
|
||||
private bool CategoryExists(int id)
|
||||
{
|
||||
return _context.Categories.Any(e => e.id == id);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,113 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace ScrumTaskboard.Controllers
|
||||
{
|
||||
[Route("[controller]")]
|
||||
[ApiController]
|
||||
public class ProjectsController : ControllerBase
|
||||
{
|
||||
private readonly TaskContext _context;
|
||||
|
||||
public ProjectsController(TaskContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
// GET: api/projects
|
||||
[HttpGet]
|
||||
public async Task<ActionResult<IEnumerable<ScrumProject>>> GetProject()
|
||||
{
|
||||
return await _context.Projects.ToListAsync();
|
||||
}
|
||||
|
||||
// GET: api/projects/5
|
||||
[HttpGet("{id}")]
|
||||
public async Task<ActionResult<ScrumProject>> GetProjects(int id)
|
||||
{
|
||||
var Project = await _context.Projects.FindAsync(id);
|
||||
|
||||
if (Project == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return Project;
|
||||
}
|
||||
|
||||
// PUT: api/Project/5
|
||||
[HttpPut("{id}")]
|
||||
public async Task<IActionResult> PutProject(int id, ScrumProject projects)
|
||||
{
|
||||
// Die ID des Projects darf nicht geändert werden
|
||||
if (id != projects.id)
|
||||
{
|
||||
return BadRequest();
|
||||
}
|
||||
|
||||
// Speichere den geänderten Project im Context
|
||||
_context.Entry(projects).State = EntityState.Modified;
|
||||
|
||||
try
|
||||
{
|
||||
// Übernehme die Änderungen in die Datenbank
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
catch (DbUpdateConcurrencyException)
|
||||
{
|
||||
// Wenn der Project nicht existiert, gib Statuscode 404 zurück
|
||||
if (!ProjectExists(id))
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
return NoContent();
|
||||
}
|
||||
|
||||
// POST: api/Project
|
||||
[HttpPost]
|
||||
public async Task<ActionResult<ScrumProject>> PostProject(ScrumProject projects)
|
||||
{
|
||||
_context.Projects.Add(projects);
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
// Der neue Project wurde erstellt und kann über die GetProject Methode abgerufen werden.
|
||||
return CreatedAtAction("GetProject", new { id = projects.id }, projects);
|
||||
}
|
||||
|
||||
// DELETE: api/Project/5
|
||||
[HttpDelete("{id}")]
|
||||
public async Task<ActionResult<ScrumProject>> DeleteProject(int id)
|
||||
{
|
||||
var scrumProject = await _context.Projects.FindAsync(id);
|
||||
if (scrumProject == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
// Entferne den Project aus dem Context
|
||||
_context.Projects.Remove(scrumProject);
|
||||
// Speichere die Änderungen in der Datenbank
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
return scrumProject;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Prüft, ob ein Project mit der angegebenen ID bereits existiert.
|
||||
/// </summary>
|
||||
private bool ProjectExists(int id)
|
||||
{
|
||||
return _context.Projects.Any(e => e.id == id);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,114 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace ScrumTaskboard.Controllers
|
||||
{
|
||||
[Route("[controller]")]
|
||||
[ApiController]
|
||||
public class SprintsController : ControllerBase
|
||||
{
|
||||
private readonly TaskContext _context;
|
||||
|
||||
public SprintsController(TaskContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
// GET: api/sprint
|
||||
[HttpGet]
|
||||
public async Task<ActionResult<IEnumerable<ScrumSprint>>> GetSprint()
|
||||
{
|
||||
return await _context.Sprints.ToListAsync();
|
||||
}
|
||||
|
||||
// GET: api/sprint/5
|
||||
[HttpGet("{id}")]
|
||||
public async Task<ActionResult<ScrumSprint>> GetSprint(int id)
|
||||
{
|
||||
var Sprint = await _context.Sprints.FindAsync(id);
|
||||
|
||||
if (Sprint == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return Sprint;
|
||||
}
|
||||
|
||||
// PUT: api/sprint/5
|
||||
[HttpPut("{id}")]
|
||||
public async Task<IActionResult> PutSprint(int id, ScrumSprint sprint)
|
||||
{
|
||||
// Die ID des Sprints darf nicht geändert werden
|
||||
if (id != sprint.id)
|
||||
{
|
||||
return BadRequest();
|
||||
}
|
||||
|
||||
// Speichere den geänderten Sprint im Context
|
||||
_context.Entry(sprint).State = EntityState.Modified;
|
||||
|
||||
try
|
||||
{
|
||||
// Übernehme die Änderungen in die Datenbank
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
catch (DbUpdateConcurrencyException)
|
||||
{
|
||||
// Wenn der Sprint nicht existiert, gib Statuscode 404 zurück
|
||||
if (!SprintExists(id))
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
return NoContent();
|
||||
}
|
||||
|
||||
// POST: api/Sprint
|
||||
[HttpPost]
|
||||
public async Task<ActionResult<ScrumSprint>> PostSprint(ScrumSprint sprint)
|
||||
{
|
||||
_context.Sprints.Add(sprint);
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
// Der neue Sprint wurde erstellt und kann über die GetSprint Methode abgerufen werden.
|
||||
return CreatedAtAction("GetSprint", new { id = sprint.id }, sprint);
|
||||
}
|
||||
|
||||
// DELETE: api/Sprint/5
|
||||
[HttpDelete("{id}")]
|
||||
public async Task<ActionResult<ScrumSprint>> DeleteSprint(int id)
|
||||
{
|
||||
var scrumSprint = await _context.Sprints.FindAsync(id);
|
||||
if (scrumSprint == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
// Entferne den Sprint aus dem Context
|
||||
_context.Sprints.Remove(scrumSprint);
|
||||
// Speichere die Änderungen in der Datenbank
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
return scrumSprint;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Prüft, ob ein Sprint mit der angegebenen ID bereits existiert.
|
||||
/// </summary>
|
||||
private bool SprintExists(int id)
|
||||
{
|
||||
return _context.Sprints.Any(e => e.id == id);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,114 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace ScrumTaskboard.Controllers
|
||||
{
|
||||
[Route("[controller]")]
|
||||
[ApiController]
|
||||
public class StatusController : ControllerBase
|
||||
{
|
||||
private readonly TaskContext _context;
|
||||
|
||||
public StatusController(TaskContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
// GET: api/status
|
||||
[HttpGet]
|
||||
public async Task<ActionResult<IEnumerable<ScrumStatus>>> GetStatus()
|
||||
{
|
||||
return await _context.Status.ToListAsync();
|
||||
}
|
||||
|
||||
// GET: api/status/1
|
||||
[HttpGet("{id}")]
|
||||
public async Task<ActionResult<ScrumStatus>> GetStatus(int id)
|
||||
{
|
||||
var userstory = await _context.Status.FindAsync(id);
|
||||
|
||||
if (userstory == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return userstory;
|
||||
}
|
||||
|
||||
// PUT: api/status/1
|
||||
[HttpPut("{id}")]
|
||||
public async Task<IActionResult> PutStatus(int id, ScrumStatus userstory)
|
||||
{
|
||||
// Die ID des Status darf nicht geändert werden
|
||||
if (id != userstory.id)
|
||||
{
|
||||
return BadRequest();
|
||||
}
|
||||
|
||||
// Speichere deb geänderten Status im Context
|
||||
_context.Entry(userstory).State = EntityState.Modified;
|
||||
|
||||
try
|
||||
{
|
||||
// Übernehme die Änderungen in die Datenbank
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
catch (DbUpdateConcurrencyException)
|
||||
{
|
||||
// Wenn der Status nicht existiert, gib Statuscode 404 zurück
|
||||
if (!StatusExists(id))
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
return NoContent();
|
||||
}
|
||||
|
||||
// POST: api/status
|
||||
[HttpPost]
|
||||
public async Task<ActionResult<ScrumStatus>> PostTask(ScrumStatus userstory)
|
||||
{
|
||||
_context.Status.Add(userstory);
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
// Der neue Status wurde erstellt und kann über die GetStatus Methode abgerufen werden.
|
||||
return CreatedAtAction("GetStatus", new { id = userstory.id }, userstory);
|
||||
}
|
||||
|
||||
// DELETE: api/status/1
|
||||
[HttpDelete("{id}")]
|
||||
public async Task<ActionResult<ScrumStatus>> DeleteStatus(int id)
|
||||
{
|
||||
var userstory = await _context.Status.FindAsync(id);
|
||||
if (userstory == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
// Entferne den Status aus dem Context
|
||||
_context.Status.Remove(userstory);
|
||||
// Speichere die Änderungen in der Datenbank
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
return userstory;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Prüft, ob ein Status mit der angegebenen ID bereits existiert.
|
||||
/// </summary>
|
||||
private bool StatusExists(int id)
|
||||
{
|
||||
return _context.Status.Any(e => e.id == id);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,114 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace ScrumTaskboard.Controllers
|
||||
{
|
||||
[Route("[controller]")]
|
||||
[ApiController]
|
||||
public class UsersController : ControllerBase
|
||||
{
|
||||
private readonly TaskContext _context;
|
||||
|
||||
public UsersController(TaskContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
// GET: api/sprint
|
||||
[HttpGet]
|
||||
public async Task<ActionResult<IEnumerable<ScrumUser>>> GetUser()
|
||||
{
|
||||
return await _context.Users.ToListAsync();
|
||||
}
|
||||
|
||||
// GET: api/sprint/5
|
||||
[HttpGet("{id}")]
|
||||
public async Task<ActionResult<ScrumUser>> GetUser(int id)
|
||||
{
|
||||
var User = await _context.Users.FindAsync(id);
|
||||
|
||||
if (User == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return User;
|
||||
}
|
||||
|
||||
// PUT: api/sprint/5
|
||||
[HttpPut("{id}")]
|
||||
public async Task<IActionResult> PutUser(int id, ScrumUser sprint)
|
||||
{
|
||||
// Die ID des Users darf nicht geändert werden
|
||||
if (id != sprint.id)
|
||||
{
|
||||
return BadRequest();
|
||||
}
|
||||
|
||||
// Speichere den geänderten User im Context
|
||||
_context.Entry(sprint).State = EntityState.Modified;
|
||||
|
||||
try
|
||||
{
|
||||
// Übernehme die Änderungen in die Datenbank
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
catch (DbUpdateConcurrencyException)
|
||||
{
|
||||
// Wenn der User nicht existiert, gib Statuscode 404 zurück
|
||||
if (!UserExists(id))
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
return NoContent();
|
||||
}
|
||||
|
||||
// POST: api/User
|
||||
[HttpPost]
|
||||
public async Task<ActionResult<ScrumUser>> PostUser(ScrumUser sprint)
|
||||
{
|
||||
_context.Users.Add(sprint);
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
// Der neue User wurde erstellt und kann über die GetUser Methode abgerufen werden.
|
||||
return CreatedAtAction("GetUser", new { id = sprint.id }, sprint);
|
||||
}
|
||||
|
||||
// DELETE: api/User/5
|
||||
[HttpDelete("{id}")]
|
||||
public async Task<ActionResult<ScrumUser>> DeleteUser(int id)
|
||||
{
|
||||
var scrumUser = await _context.Users.FindAsync(id);
|
||||
if (scrumUser == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
// Entferne den User aus dem Context
|
||||
_context.Users.Remove(scrumUser);
|
||||
// Speichere die Änderungen in der Datenbank
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
return scrumUser;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Prüft, ob ein User mit der angegebenen ID bereits existiert.
|
||||
/// </summary>
|
||||
private bool UserExists(int id)
|
||||
{
|
||||
return _context.Users.Any(e => e.id == id);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,115 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using ScrumTaskboard;
|
||||
|
||||
namespace ScrumTaskboard.Controllers
|
||||
{
|
||||
[Route("[controller]")]
|
||||
[ApiController]
|
||||
public class UserstoriesController : ControllerBase
|
||||
{
|
||||
private readonly TaskContext _context;
|
||||
|
||||
public UserstoriesController(TaskContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
// GET: api/userstories
|
||||
[HttpGet]
|
||||
public async Task<ActionResult<IEnumerable<ScrumUserstory>>> GetUserstory()
|
||||
{
|
||||
return await _context.Userstories.ToListAsync();
|
||||
}
|
||||
|
||||
// GET: api/userstories/1
|
||||
[HttpGet("{id}")]
|
||||
public async Task<ActionResult<ScrumUserstory>> GetUserstory(int id)
|
||||
{
|
||||
var userstory = await _context.Userstories.FindAsync(id);
|
||||
|
||||
if (userstory == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return userstory;
|
||||
}
|
||||
|
||||
// PUT: api/userstories/1
|
||||
[HttpPut("{id}")]
|
||||
public async Task<IActionResult> PutUserstory(int id, ScrumUserstory userstory)
|
||||
{
|
||||
// Die ID der Userstory darf nicht geändert werden
|
||||
if (id != userstory.id)
|
||||
{
|
||||
return BadRequest();
|
||||
}
|
||||
|
||||
// Speichere die geänderten Userstory im Context
|
||||
_context.Entry(userstory).State = EntityState.Modified;
|
||||
|
||||
try
|
||||
{
|
||||
// Übernehme die Änderungen in die Datenbank
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
catch (DbUpdateConcurrencyException)
|
||||
{
|
||||
// Wenn die Userstory nicht existiert, gib Statuscode 404 zurück
|
||||
if (!UserstoryExists(id))
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
return NoContent();
|
||||
}
|
||||
|
||||
// POST: api/userstories
|
||||
[HttpPost]
|
||||
public async Task<ActionResult<ScrumUserstory>> PostTask(ScrumUserstory userstory)
|
||||
{
|
||||
_context.Userstories.Add(userstory);
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
// Die neue Userstory wurde erstellt und kann über die GetUserstory Methode abgerufen werden.
|
||||
return CreatedAtAction("GetUserstory", new { id = userstory.id }, userstory);
|
||||
}
|
||||
|
||||
// DELETE: api/userstories/1
|
||||
[HttpDelete("{id}")]
|
||||
public async Task<ActionResult<ScrumUserstory>> DeleteUserstory(int id)
|
||||
{
|
||||
var userstory = await _context.Userstories.FindAsync(id);
|
||||
if (userstory == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
// Entferne die Userstory aus dem Context
|
||||
_context.Userstories.Remove(userstory);
|
||||
// Speichere die Änderungen in der Datenbank
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
return userstory;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Prüft, ob eine Userstory mit der angegebenen ID bereits existiert.
|
||||
/// </summary>
|
||||
private bool UserstoryExists(int id)
|
||||
{
|
||||
return _context.Userstories.Any(e => e.id == id);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -12,6 +12,7 @@
|
|||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="3.1.0-preview1.19506.1" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.3" />
|
||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="3.1.3" />
|
||||
</ItemGroup>
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text.Json.Serialization;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
|
@ -25,6 +26,7 @@ namespace ScrumTaskboard
|
|||
|
||||
// This method gets called by the runtime. Use this method to add services to the container.
|
||||
public void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
{
|
||||
services.AddCors(o => o.AddPolicy("AllowAll", builder =>
|
||||
{
|
||||
|
@ -35,7 +37,11 @@ namespace ScrumTaskboard
|
|||
services.AddScoped(serviceProvider => new TaskContext(
|
||||
new DbContextOptionsBuilder<TaskContext>()
|
||||
.UseNpgsql(GetConnectionString())
|
||||
.Options));
|
||||
services.AddMvc().AddJsonOptions(o =>
|
||||
{
|
||||
o.JsonSerializerOptions.Converters.Add(new JsonStringEnumConverter());
|
||||
o.JsonSerializerOptions.IgnoreNullValues = true;
|
||||
});
|
||||
services.AddControllers();
|
||||
}
|
||||
|
||||
|
@ -65,36 +71,5 @@ namespace ScrumTaskboard
|
|||
endpoints.MapControllers();
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates DB Connection String based on ENV vars and default vars.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public string GetConnectionString()
|
||||
{
|
||||
string dbHost;
|
||||
string dbPort;
|
||||
string dbName;
|
||||
string dbUser;
|
||||
string dbPassword;
|
||||
|
||||
dbHost = Environment.GetEnvironmentVariable("DATABASE_HOST");
|
||||
dbPort = Environment.GetEnvironmentVariable("DATABASE_PORT");
|
||||
dbName = Environment.GetEnvironmentVariable("DATABASE_NAME");
|
||||
dbUser = Environment.GetEnvironmentVariable("DATABASE_USER");
|
||||
dbPassword = Environment.GetEnvironmentVariable("DATABASE_PASSWORD");
|
||||
|
||||
if(dbHost == null || dbPort == null || dbName == null || dbUser == null || dbPassword == null)
|
||||
{
|
||||
dbHost = "nig.gl";
|
||||
dbPort = "8543";
|
||||
dbName = "taskboard";
|
||||
dbUser = "scrum";
|
||||
dbPassword = "c6gXud7YvBWp2sgxSgy4wRN";
|
||||
}
|
||||
|
||||
|
||||
return $"Host={dbHost}; Port={dbPort}; Username={dbUser}; Database={dbName}; Password={dbPassword}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,18 @@
|
|||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace ScrumTaskboard
|
||||
{
|
||||
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; }
|
||||
|
||||
public TaskContext() { }
|
||||
|
||||
|
@ -23,5 +30,67 @@ namespace ScrumTaskboard
|
|||
public int sprint { get; set; }
|
||||
public int project { get; set; }
|
||||
public int userstory { get; set; }
|
||||
public ScrumPrio priority { get; set; }
|
||||
}
|
||||
|
||||
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 status { get; set; }
|
||||
public int category { get; set; }
|
||||
public int createdby { get; set; }
|
||||
public int project { get; set; }
|
||||
}
|
||||
|
||||
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 project { get; set; }
|
||||
}
|
||||
|
||||
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 project { get; set; }
|
||||
}
|
||||
|
||||
public class ScrumStatus
|
||||
{
|
||||
public int id { get; set; }
|
||||
public string title { get; set; }
|
||||
public string description { get; set; }
|
||||
}
|
||||
|
||||
public class ScrumProject
|
||||
{
|
||||
public int id { get; set; }
|
||||
public string title { get; set; }
|
||||
public bool isprivate { get; set; }
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue