Merge branch 'comments/task-context' into comments/merge
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user