fix everything (#72)
fix everything Co-authored-by: MaxchilKH <m.w.bohdanowicz@gmail.com>
This commit is contained in:
parent
80dda549bf
commit
3b60331091
@ -116,7 +116,7 @@ namespace InternshipSystem.Api.Controllers
|
|||||||
return Ok();
|
return Ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("{documentId}/scan")]
|
[HttpGet("{documentId}/scan/download")]
|
||||||
[Authorize(Policy = Policies.RegisteredOnly)]
|
[Authorize(Policy = Policies.RegisteredOnly)]
|
||||||
public async Task<ActionResult> GetDocumentScan(long documentId, [FromQuery] string disposition, [FromServices] User user, CancellationToken cancellationToken)
|
public async Task<ActionResult> GetDocumentScan(long documentId, [FromQuery] string disposition, [FromServices] User user, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
@ -146,5 +146,33 @@ namespace InternshipSystem.Api.Controllers
|
|||||||
|
|
||||||
return File(stream, document.Scan.Mime);
|
return File(stream, document.Scan.Mime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpGet("{documentId}/scan")]
|
||||||
|
[Authorize(Policy = Policies.RegisteredOnly)]
|
||||||
|
public async Task<ActionResult> GetDocumentScanData(long documentId, [FromServices] User user, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
var edition = await _context.Editions.FirstAsync(e => e.Id == user.EditionId, cancellationToken);
|
||||||
|
|
||||||
|
var internship =
|
||||||
|
await _context.Entry(edition)
|
||||||
|
.Collection(e => e.Internships)
|
||||||
|
.Query()
|
||||||
|
.FirstAsync(i => i.Student.Id == user.PersonNumber, cancellationToken);
|
||||||
|
|
||||||
|
var scan =
|
||||||
|
await _context.Entry(internship)
|
||||||
|
.Collection(i => i.Documentation)
|
||||||
|
.Query()
|
||||||
|
.Include(d => d.Scan)
|
||||||
|
.Select(s => new {s.Id, s.Scan.Filename, s.Scan.Mime, s.Scan.Size})
|
||||||
|
.FirstOrDefaultAsync(d => d.Id == documentId, cancellationToken);
|
||||||
|
|
||||||
|
if (scan == null)
|
||||||
|
{
|
||||||
|
return NotFound();
|
||||||
|
}
|
||||||
|
|
||||||
|
return Ok(scan);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -38,6 +38,7 @@ namespace InternshipSystem.Api.Controllers
|
|||||||
{
|
{
|
||||||
var edition = await _context.Editions
|
var edition = await _context.Editions
|
||||||
.Include(e => e.Internships)
|
.Include(e => e.Internships)
|
||||||
|
.ThenInclude(i => i.Student)
|
||||||
.FirstOrDefaultAsync(e => e.Id.Equals(registrationCode), cancellationToken: token);
|
.FirstOrDefaultAsync(e => e.Id.Equals(registrationCode), cancellationToken: token);
|
||||||
|
|
||||||
if (edition == null)
|
if (edition == null)
|
||||||
|
Loading…
Reference in New Issue
Block a user