scan fix
This commit is contained in:
parent
abd131e383
commit
5038008bd0
@ -1,6 +1,5 @@
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net.Mime;
|
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using InternshipSystem.Api.Queries;
|
using InternshipSystem.Api.Queries;
|
||||||
@ -61,9 +60,11 @@ 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)
|
||||||
.FirstAsync(i => i.Student.Id == user.PersonNumber, cancellationToken);
|
.FirstAsync(i => i.Student.Id == user.PersonNumber, cancellationToken);
|
||||||
|
|
||||||
internship.AddNewDocument(documentRequest.Description, documentRequest.Type);
|
internship.AddNewDocument(documentRequest.Description, documentRequest.Type);
|
||||||
|
await _context.SaveChangesAsync(cancellationToken);
|
||||||
|
|
||||||
return Ok();
|
return Ok();
|
||||||
}
|
}
|
||||||
@ -86,14 +87,12 @@ 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)
|
||||||
.FirstAsync(i => i.Student.Id == user.PersonNumber, cancellationToken);
|
.FirstAsync(i => i.Student.Id == user.PersonNumber, cancellationToken);
|
||||||
|
|
||||||
var document = await _context.Entry(internship)
|
var document = internship.Documentation.First(d => d.Id == documentId);
|
||||||
.Collection(i => i.Documentation)
|
|
||||||
.Query()
|
|
||||||
.FirstOrDefaultAsync(d => d.Id == documentId, cancellationToken);
|
|
||||||
|
|
||||||
document.Scan = memoryStream.ToArray();
|
document.Scan = new DocumentScan { File = memoryStream.ToArray() };
|
||||||
document.State = DocumentState.Submitted;
|
document.State = DocumentState.Submitted;
|
||||||
|
|
||||||
await _context.SaveChangesAsync(cancellationToken);
|
await _context.SaveChangesAsync(cancellationToken);
|
||||||
@ -117,9 +116,10 @@ namespace InternshipSystem.Api.Controllers
|
|||||||
await _context.Entry(internship)
|
await _context.Entry(internship)
|
||||||
.Collection(i => i.Documentation)
|
.Collection(i => i.Documentation)
|
||||||
.Query()
|
.Query()
|
||||||
|
.Include(d => d.Scan)
|
||||||
.FirstOrDefaultAsync(d => d.Id == documentId, cancellationToken);
|
.FirstOrDefaultAsync(d => d.Id == documentId, cancellationToken);
|
||||||
|
|
||||||
var stream = new MemoryStream(document.Scan);
|
var stream = new MemoryStream(document.Scan.File);
|
||||||
|
|
||||||
return File(stream, "application/pdf");
|
return File(stream, "application/pdf");
|
||||||
}
|
}
|
||||||
|
@ -6,9 +6,16 @@ namespace InternshipSystem.Core
|
|||||||
{
|
{
|
||||||
public long Id { get; set; }
|
public long Id { get; set; }
|
||||||
public string Description { get; set; }
|
public string Description { get; set; }
|
||||||
public byte[] Scan { get; set; }
|
public DocumentScan Scan { get; set; }
|
||||||
public DocumentType Type { get; set; }
|
public DocumentType Type { get; set; }
|
||||||
public DocumentState State { get; set; }
|
public DocumentState State { get; set; }
|
||||||
public string RejectionReason { get; set; }
|
public string RejectionReason { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class DocumentScan
|
||||||
|
{
|
||||||
|
public long DocumentId { get; set; }
|
||||||
|
public Document Document { get; set; }
|
||||||
|
public byte[] File { get; set; }
|
||||||
|
}
|
||||||
}
|
}
|
@ -45,8 +45,8 @@ namespace InternshipSystem.Core.Entity.Internship
|
|||||||
{
|
{
|
||||||
var document = Documentation.First(d => d.Id == documentId);
|
var document = Documentation.First(d => d.Id == documentId);
|
||||||
|
|
||||||
document.Scan = documentScan;
|
// document.Scan = documentScan;
|
||||||
document.State = DocumentState.Submitted;
|
// document.State = DocumentState.Submitted;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user