Merge branch 'comments/task-context' into comments/merge

This commit is contained in:
2020-07-14 18:03:33 +02:00
8 changed files with 219 additions and 158 deletions

View File

@@ -34,15 +34,15 @@ namespace ScrumTaskboard.Controllers
if (title != null)
{
filtered = filtered.Where<ScrumCategory>(c => c.title.Contains(title));
filtered = filtered.Where<ScrumCategory>(c => c.Title.Contains(title));
}
if (projectid != null)
{
filtered = filtered.Where<ScrumCategory>(c => c.projectid == projectid);
filtered = filtered.Where<ScrumCategory>(c => c.ProjectId == projectid);
}
if (color != null)
{
filtered = filtered.Where<ScrumCategory>(c => c.color == color);
filtered = filtered.Where<ScrumCategory>(c => c.Color == color);
}
@@ -132,7 +132,7 @@ namespace ScrumTaskboard.Controllers
/// </summary>
private bool CategoryExists(int id)
{
return _context.Categories.Any(e => e.id == id);
return _context.Categories.Any(e => e.Id == id);
}
}
}

View File

@@ -34,11 +34,11 @@ namespace ScrumTaskboard.Controllers
if (title != null)
{
filtered = filtered.Where<ScrumProject>(t => t.title.Contains(title));
filtered = filtered.Where<ScrumProject>(t => t.Title.Contains(title));
}
if (isprivate != null)
{
filtered = filtered.Where<ScrumProject>(t => t.isprivate == isprivate);
filtered = filtered.Where<ScrumProject>(t => t.IsPrivate == isprivate);
}
return await filtered.ToListAsync();
@@ -49,14 +49,14 @@ namespace ScrumTaskboard.Controllers
[HttpGet("{id}")]
public async Task<ActionResult<ScrumProject>> 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
/// </summary>
private bool ProjectExists(int id)
{
return _context.Projects.Any(e => e.id == id);
return _context.Projects.Any(e => e.Id == id);
}
}
}

View File

@@ -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
{
/// <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>
[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;
/// <param name="context"></param>
public SprintsController(TaskContext context)
{
_context = context;
}
// GET: api/sprint
#nullable enable
[HttpGet]
public async Task<ActionResult<IEnumerable<ScrumSprint>>> GetSprint([FromQuery]string? title, [FromQuery]int? projectid, [FromQuery]DateTime? startDate, [FromQuery]DateTime? endDate)
{
var filtered = _context.Sprints.AsQueryable();
if (title != null)
{
filtered = filtered.Where<ScrumSprint>(s => s.title.Contains(title));
}
if (projectid != null)
{
filtered = filtered.Where<ScrumSprint>(s => s.projectid == projectid);
}
#nullable enable
[HttpGet]
public async Task<ActionResult<IEnumerable<ScrumSprint>>> GetSprint([FromQuery]string? title, [FromQuery]int? projectid, [FromQuery]DateTime? startDate, [FromQuery]DateTime? endDate)
{
var filtered = _context.Sprints.AsQueryable();
if (title != null)
{
filtered = filtered.Where<ScrumSprint>(s => s.Title.Contains(title));
}
if (projectid != null)
{
filtered = filtered.Where<ScrumSprint>(s => s.ProjectId == projectid);
}
if (startDate != null)
{
filtered = filtered.Where<ScrumSprint>(s => s.startDate == startDate);
filtered = filtered.Where<ScrumSprint>(s => s.StartDate == startDate);
}
if (endDate != null)
{
filtered = filtered.Where<ScrumSprint>(s => s.endDate == endDate);
}
return await filtered.ToListAsync();
{
filtered = filtered.Where<ScrumSprint>(s => s.EndDate == endDate);
}
return await filtered.ToListAsync();
}
#nullable disable
@@ -57,14 +57,14 @@ namespace ScrumTaskboard.Controllers
[HttpGet("{id}")]
public async Task<ActionResult<ScrumSprint>> 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;
}
/// <summary>
/// Checks whether a sprint with the specified ID already exists.
/// </summary>
/// <summary>
/// Checks whether a sprint with the specified ID already exists.
/// </summary>
private bool SprintExists(int id)
{
return _context.Sprints.Any(e => e.id == id);
return _context.Sprints.Any(e => e.Id == id);
}
}
}
}
}

View File

@@ -33,7 +33,7 @@ namespace ScrumTaskboard.Controllers
if (title != null)
{
filtered = filtered.Where<ScrumStatus>(s => s.title.Contains(title));
filtered = filtered.Where<ScrumStatus>(s => s.Title.Contains(title));
}
return await filtered.ToListAsync();
@@ -122,7 +122,7 @@ namespace ScrumTaskboard.Controllers
/// </summary>
private bool StatusExists(int id)
{
return _context.Status.Any(e => e.id == id);
return _context.Status.Any(e => e.Id == id);
}
}
}

View File

@@ -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
{
/// <summary>
/// This is a controller of Tasks class includes all API's related to the Tasks.
/// <summary>
/// This is a controller of Tasks class includes all API's related to the Tasks.
/// </summary>
[Route("[controller]")]
[ApiController]
@@ -16,53 +16,53 @@ namespace ScrumTaskboard.Controllers
{
private readonly TaskContext _context;
/// <summary>
/// Initializes a new instance of the class.
/// </summary>
/// <summary>
/// Initializes a new instance of the class.
/// </summary>
/// <param name="context"></param>
public TasksController(TaskContext context)
{
_context = context;
}
// GET: api/tasks
}
// GET: api/tasks
#nullable enable
[HttpGet]
public async Task<ActionResult<IEnumerable<ScrumTask>>> 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<ScrumTask>(t => t.title.Contains(title));
if (title != null)
{
filtered = filtered.Where<ScrumTask>(t => t.Title.Contains(title));
}
if (userstoryid != null)
{
filtered = filtered.Where<ScrumTask>(t => t.userstoryid == userstoryid);
if (userstoryid != null)
{
filtered = filtered.Where<ScrumTask>(t => t.UserstoryId == userstoryid);
}
if (statusid != null)
{
filtered = filtered.Where<ScrumTask>(t => t.statusid == statusid);
if (statusid != null)
{
filtered = filtered.Where<ScrumTask>(t => t.StatusId == statusid);
}
if (assignedtoid != null)
{
filtered = filtered.Where<ScrumTask>(t => t.assignedtoid == assignedtoid);
if (assignedtoid != null)
{
filtered = filtered.Where<ScrumTask>(t => t.AssignedToId == assignedtoid);
}
if (projectid != null)
{
filtered = filtered.Where<ScrumTask>(t => t.projectid == projectid);
if (projectid != null)
{
filtered = filtered.Where<ScrumTask>(t => t.ProjectId == projectid);
}
if (priority != null)
{
filtered = filtered.Where<ScrumTask>(t => t.priority == priority);
}
if (priority != null)
{
filtered = filtered.Where<ScrumTask>(t => t.Priority == priority);
}
return await filtered.ToListAsync();
}
}
#nullable disable
// GET: api/tasks/5
// GET: api/tasks/5
[HttpGet("{id}")]
public async Task<ActionResult<ScrumTask>> GetTask(int id)
{
@@ -144,7 +144,7 @@ namespace ScrumTaskboard.Controllers
/// </summary>
private bool TaskExists(int id)
{
return _context.Tasks.Any(e => e.id == id);
return _context.Tasks.Any(e => e.Id == id);
}
}
}

View File

@@ -32,7 +32,7 @@ namespace ScrumTaskboard.Controllers
var filtered = _context.Users.AsQueryable();
if (name != null)
{
filtered = filtered.Where<ScrumUser>(u => u.name.Contains(name));
filtered = filtered.Where<ScrumUser>(u => u.Name.Contains(name));
}
return await filtered.ToListAsync();
@@ -43,14 +43,14 @@ namespace ScrumTaskboard.Controllers
[HttpGet("{id}")]
public async Task<ActionResult<ScrumUser>> 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
/// </summary>
private bool UserExists(int id)
{
return _context.Users.Any(e => e.id == id);
return _context.Users.Any(e => e.Id == id);
}
}
}

View File

@@ -34,31 +34,31 @@ namespace ScrumTaskboard.Controllers
if (title != null)
{
filtered = filtered.Where<ScrumUserstory>(t => t.title.Contains(title));
filtered = filtered.Where<ScrumUserstory>(t => t.Title.Contains(title));
}
if (statusid != null)
{
filtered = filtered.Where<ScrumUserstory>(t => t.statusid == statusid);
filtered = filtered.Where<ScrumUserstory>(t => t.StatusId == statusid);
}
if (categoryid != null)
{
filtered = filtered.Where<ScrumUserstory>(t => t.categoryid == categoryid);
filtered = filtered.Where<ScrumUserstory>(t => t.CategoryId == categoryid);
}
if (createdbyid != null)
{
filtered = filtered.Where<ScrumUserstory>(t => t.createdbyid == createdbyid);
filtered = filtered.Where<ScrumUserstory>(t => t.CreatedById == createdbyid);
}
if (projectid != null)
{
filtered = filtered.Where<ScrumUserstory>(t => t.projectid == projectid);
filtered = filtered.Where<ScrumUserstory>(t => t.ProjectId == projectid);
}
if (sprintid != null)
{
filtered = filtered.Where<ScrumUserstory>(t => t.sprintid == sprintid);
filtered = filtered.Where<ScrumUserstory>(t => t.SprintId == sprintid);
}
if (priority != null)
{
filtered = filtered.Where<ScrumUserstory>(t => t.priority == priority);
filtered = filtered.Where<ScrumUserstory>(t => t.Priority == priority);
}
@@ -148,7 +148,7 @@ namespace ScrumTaskboard.Controllers
/// </summary>
private bool UserstoryExists(int id)
{
return _context.Userstories.Any(e => e.id == id);
return _context.Userstories.Any(e => e.Id == id);
}
}
}