Add support for invoice attachments
Introduced the `InvoiceAttachment` entity and its relationship with `ZugferdInvoice` to manage extracted invoice attachments. Updated `AppDbContext` and added a migration to create the `InvoiceAttachments` table with cascading delete behavior and an index for optimized queries. Enhanced the UI to display attachments in `Details.cshtml`, including file type icons, file size, and extraction date. Added a new `ViewAttachment` page to render or download attachments based on their type, with support for XML, plain text, images, and downloads. Implemented `AttachmentViewerService` to determine viewer types and MIME types for attachments. Registered the service in the DI container. Updated `Upload.cshtml.cs` to save extracted attachments to the database. Improved user experience with syntax highlighting for XML files and appropriate messages for unsupported file types.
This commit is contained in:
@@ -22,6 +22,40 @@ namespace DXApp.TemplateKitProject.Migrations
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("DXApp.TemplateKitProject.Models.InvoiceAttachment", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<DateTime>("ExtractedAt")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<long>("FileSizeBytes")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<bool>("IsZugferdXml")
|
||||
.HasColumnType("bit");
|
||||
|
||||
b.Property<string>("OriginalFileName")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("SavedFilePath")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("ZugferdInvoiceId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ZugferdInvoiceId")
|
||||
.HasDatabaseName("IX_InvoiceAttachments_ZugferdInvoiceId");
|
||||
|
||||
b.ToTable("InvoiceAttachments");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DXApp.TemplateKitProject.Models.ZugferdInvoice", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
@@ -82,6 +116,22 @@ namespace DXApp.TemplateKitProject.Migrations
|
||||
|
||||
b.ToTable("ZugferdInvoices");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DXApp.TemplateKitProject.Models.InvoiceAttachment", b =>
|
||||
{
|
||||
b.HasOne("DXApp.TemplateKitProject.Models.ZugferdInvoice", "ZugferdInvoice")
|
||||
.WithMany("Attachments")
|
||||
.HasForeignKey("ZugferdInvoiceId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("ZugferdInvoice");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DXApp.TemplateKitProject.Models.ZugferdInvoice", b =>
|
||||
{
|
||||
b.Navigation("Attachments");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user