-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into update-test-seeding
- Loading branch information
Showing
12 changed files
with
3,318 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
using BDMS.Authentication; | ||
using BDMS.Models; | ||
using Microsoft.AspNetCore.Authorization; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.EntityFrameworkCore; | ||
|
||
namespace BDMS.Controllers; | ||
|
||
[ApiController] | ||
[Route("api/v{version:apiVersion}/[controller]")] | ||
public class BackfillController : BdmsControllerBase<Backfill> | ||
{ | ||
public BackfillController(BdmsContext context, ILogger<Backfill> logger) | ||
: base(context, logger) | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Asynchronously gets the <see cref="Backfill"/>s, optionally filtered by <paramref name="completionId"/>. | ||
/// </summary> | ||
/// <param name="completionId">The id of the completion containing the <see cref="Backfill"/> to get.</param> | ||
[HttpGet] | ||
[Authorize(Policy = PolicyNames.Viewer)] | ||
public async Task<IEnumerable<Backfill>> GetAsync([FromQuery] int? completionId = null) | ||
{ | ||
var backfills = Context.Backfills | ||
.Include(i => i.Material) | ||
.Include(i => i.Kind) | ||
.AsNoTracking(); | ||
|
||
if (completionId != null) | ||
{ | ||
backfills = backfills.Where(i => i.CompletionId == completionId); | ||
} | ||
|
||
return await backfills.ToListAsync().ConfigureAwait(false); | ||
} | ||
|
||
/// <summary> | ||
/// Asynchronously gets the <see cref="Backfill"/> with the specified <paramref name="id"/>. | ||
/// </summary> | ||
[HttpGet("{id}")] | ||
[Authorize(Policy = PolicyNames.Viewer)] | ||
public async Task<ActionResult<Backfill>> GetByIdAsync(int id) | ||
{ | ||
var backfill = await Context.Backfills | ||
.Include(i => i.Material) | ||
.Include(i => i.Kind) | ||
.AsNoTracking() | ||
.SingleOrDefaultAsync(i => i.Id == id) | ||
.ConfigureAwait(false); | ||
|
||
if (backfill == null) | ||
{ | ||
return NotFound(); | ||
} | ||
|
||
return Ok(backfill); | ||
} | ||
|
||
/// <inheritdoc /> | ||
[Authorize(Policy = PolicyNames.Viewer)] | ||
public override Task<ActionResult<Backfill>> CreateAsync(Backfill entity) | ||
=> base.CreateAsync(entity); | ||
|
||
/// <inheritdoc /> | ||
[Authorize(Policy = PolicyNames.Viewer)] | ||
public override Task<ActionResult<Backfill>> EditAsync(Backfill entity) | ||
=> base.EditAsync(entity); | ||
|
||
/// <inheritdoc /> | ||
[Authorize(Policy = PolicyNames.Viewer)] | ||
public override Task<IActionResult> DeleteAsync(int id) | ||
=> base.DeleteAsync(id); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.