fix/scan (#80)
form dum dum Co-authored-by: MaxchilKH <m.w.bohdanowicz@gmail.com>
This commit is contained in:
parent
2176fbe661
commit
6d1103a6b9
@ -96,21 +96,24 @@ namespace InternshipSystem.Api.Controllers
|
|||||||
await _context.Entry(edition)
|
await _context.Entry(edition)
|
||||||
.Collection(e => e.Internships)
|
.Collection(e => e.Internships)
|
||||||
.Query()
|
.Query()
|
||||||
.Include(i => i.Documentation)
|
.Include(i => i.Documentation)
|
||||||
.FirstAsync(i => i.Student.Id == user.PersonNumber, cancellationToken);
|
.FirstAsync(i => i.Student.Id == user.PersonNumber, cancellationToken);
|
||||||
|
|
||||||
var document = internship.Documentation.First(d => d.Id == documentId);
|
var document = await _context.Entry(internship)
|
||||||
|
.Collection(i => i.Documentation)
|
||||||
|
.Query()
|
||||||
|
.Include(d => d.Scan)
|
||||||
|
.FirstAsync(d => d.Id == documentId, cancellationToken);
|
||||||
|
|
||||||
|
document.Scan ??= new DocumentScan();
|
||||||
|
|
||||||
|
document.Scan.Size = memoryStream.Length;
|
||||||
|
document.Scan.Filename = documentScan.FileName;
|
||||||
|
document.Scan.Mime = _fileValidator.GetFileMime(memoryStream.ToArray());
|
||||||
|
document.Scan.File = memoryStream.ToArray();
|
||||||
|
|
||||||
document.Scan = new DocumentScan
|
|
||||||
{
|
|
||||||
File = memoryStream.ToArray(),
|
|
||||||
Size = memoryStream.Length,
|
|
||||||
Filename = documentScan.FileName,
|
|
||||||
Mime = _fileValidator.GetFileMime(memoryStream.ToArray())
|
|
||||||
};
|
|
||||||
|
|
||||||
document.State = DocumentState.Submitted;
|
document.State = DocumentState.Submitted;
|
||||||
|
|
||||||
await _context.SaveChangesAsync(cancellationToken);
|
await _context.SaveChangesAsync(cancellationToken);
|
||||||
|
|
||||||
return Ok();
|
return Ok();
|
||||||
|
Loading…
Reference in New Issue
Block a user