fix/scan (#80)

form

dum dum

Co-authored-by: MaxchilKH <m.w.bohdanowicz@gmail.com>
This commit is contained in:
maxchil 2020-11-12 00:26:46 +01:00
parent 2176fbe661
commit 6d1103a6b9

View File

@ -96,21 +96,24 @@ namespace InternshipSystem.Api.Controllers
await _context.Entry(edition)
.Collection(e => e.Internships)
.Query()
.Include(i => i.Documentation)
.Include(i => i.Documentation)
.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;
await _context.SaveChangesAsync(cancellationToken);
return Ok();