コード例 #1
0
        public Task <CephFileId> Save(FileWithMetadata fileWithMetadata)
        {
            var rawGuid = Guid.NewGuid();
            var fileId  = new CephFileId(rawGuid);

            _files.Add(fileId, fileWithMetadata);

            return(Task.FromResult(fileId));
        }
コード例 #2
0
        public async Task <WaybillFile> Get(CephFileId cephFileId)
        {
            var file = await _fileRepository.Get(cephFileId);

            var waybillFileDto =
                await _context.WaybillFiles.SingleOrDefaultAsync(
                    x => x.CephId == cephFileId.ToGuid());

            var excelFile = _excelFileFactory.Create(
                waybillFileDto.Name,
                new MemoryStream(file.FileContent.ToArray()));

            return(new WaybillFileWithId(cephFileId, excelFile, waybillFileDto.UploadTime));
        }
コード例 #3
0
 public FileWithMetadata(
     Guid fileId,
     string filename,
     string contentType,
     IReadOnlyCollection <string> tags,
     DateTimeOffset?createdAt,
     byte[] fileContent)
 {
     CephFileId  = new CephFileId(fileId);
     Filename    = filename;
     ContentType = contentType;
     Tags        = tags;
     CreatedAt   = createdAt;
     FileContent = new ReadOnlyCollection <byte>(fileContent);
 }
コード例 #4
0
ファイル: PaperWaybill.cs プロジェクト: amburin/Test-Tasks
 public PaperWaybill(
     WaybillId id,
     CephFileId sourceFileId,
     OrderId orderId,
     WaybillContent content,
     WaybillContentStructuralValidationResult structuralValidationResult,
     WaybillInteractionState interactionState)
     : base(
         id,
         orderId,
         content)
 {
     SourceFileId = sourceFileId;
     StructuralValidationResult = structuralValidationResult;
     InteractionState           = interactionState;
 }
コード例 #5
0
ファイル: WaybillMapper.cs プロジェクト: amburin/Test-Tasks
        public static PaperWaybill MapToPaperWaybill(this WaybillDto waybillDto)
        {
            if (waybillDto == null)
            {
                throw new ArgumentNullException(nameof(waybillDto));
            }

            var id      = new WaybillId(waybillDto.Id);
            var fileId  = new CephFileId(waybillDto.File.CephId);
            var orderId = new OrderId(waybillDto.OrderId);

            var waybillContent             = waybillDto.Content?.MapToModel();
            var structuralValidationResult = waybillDto.ValidationResult?.MapToModel();

            var interactionState = waybillDto.InteractionState.MapToModel();

            return(new PaperWaybill(
                       id: id,
                       sourceFileId: fileId,
                       orderId: orderId,
                       content: waybillContent,
                       structuralValidationResult: structuralValidationResult,
                       interactionState: interactionState));
        }
コード例 #6
0
 public WaybillFileWithId(CephFileId cephFileId, File file, DateTimeOffset uploadTime)
     : base(file, uploadTime)
 {
     Id = cephFileId;
 }
コード例 #7
0
ファイル: PaperWaybill.cs プロジェクト: amburin/Test-Tasks
 public PaperWaybill(OrderId orderId, CephFileId sourceFileId) : base(orderId)
 {
     SourceFileId = sourceFileId;
 }
コード例 #8
0
        public Task <FileWithMetadata> Get(CephFileId cephFileId)
        {
            var file = _files[cephFileId];

            return(Task.FromResult(file));
        }