Skip to content

EdiFileService

Persists and deletes parsed EDI file structures via IUnitOfWork, translating an in-memory IEdiFile (segments, data elements, and composite data elements) into the SAIF.Data.Model.Edi.EdiFile/EdiSegment/EdiDataElement persistence model.

Purpose

  • Converts a parsed IEdiFile (segments/elements/composite elements) into the EDI data-model entity graph and saves it in one transaction.
  • Deletes a previously stored EDI file by its identifier.

Context

  • Namespace: SAIF.Services.Utilities.Edi
  • Assembly/package: SAIF.Services (packaged inside the SAIF.SAIFCode.Core NuGet package)

Public members

Member Signature Purpose
EdiFileService(...) public EdiFileService(IUnitOfWork uow) Stores the unit of work used for all EDI file persistence, after verifying it is not null.
LoadFile public void LoadFile(IEdiFile file, string description) Builds an EdiFile entity (with a description and current timestamp) from file's segments/data elements/composite elements — including nested composite child elements — and commits it to the repository in one transaction.
DeleteFile public void DeleteFile(long fileId) Loads the EdiFile entity with fileId and deletes it within a transaction if found; otherwise does nothing.

Behavioral notes

  • LoadFile wraps the entire entity-graph build and insert in a single unitOfWork.Begin()/Commit() transaction.
  • Composite data elements (IEdiCompositeDataElement) are expanded into individual child EdiDataElement rows tagged with CompositeIndex, in addition to the composite element itself being added to the segment.

Sources

  • Services/SAIF.Services/Utilities/Edi/EdiFileService.cs