private static void FillContentFromModel( this WaybillDto parentDto, WaybillContent model, WaybillId waybillId) { if (model == null) { parentDto.Content = null; return; } if (parentDto.Content == null) { parentDto.Content = new WaybillContentDto(); } var dto = parentDto.Content; dto.SupplierWaybillId = waybillId.Value; dto.DocumentNumber = model.Header.DocumentNumber; dto.DocumentDate = model.Header.DocumentDate; dto.Consignee = model.Header.Consignee; dto.Items = model.Items .Select((item, i) => item.MapToDto(waybillId: waybillId, sequenceNumber: i + 1)) .ToList(); dto.TotalVat = model.Totals.TotalVatSum; dto.TotalSumWithVat = model.Totals.TotalSumWithVat; dto.TotalSumWithoutVat = model.Totals.TotalSumWithoutVat; }
public static void FillFromPaperWaybillModel(this WaybillDto dto, PaperWaybill model) { FillFromWaybillModel(dto, model); dto.SourceFileId = model.SourceFileId.ToGuid(); dto.FillValidationResult(model.StructuralValidationResult, model.Id); dto.InteractionState = model.InteractionState.MapToDto(); }
public static void FillValidationResult(this WaybillDto parentDto, WaybillContentStructuralValidationResult model, WaybillId waybillId) { if (model == null) { parentDto.ValidationResult = null; return; } if (parentDto.ValidationResult == null) { parentDto.ValidationResult = new WaybillValidationResultDto(); } var dto = parentDto.ValidationResult; dto.HasConsigneeError = model.HeaderResult.HasConsigneeError; dto.HasDocumentDateError = model.HeaderResult.HasDocumentDateError; dto.HasDocumentNumberError = model.HeaderResult.HasDocumentNumberError; dto.HasEmptySumWithoutVat = model.TotalsResult.HasEmptySumWithoutVat; dto.HasEmptyTotalVatSum = model.TotalsResult.HasEmptyTotalVatSum; dto.HasEmptySumWithVat = model.TotalsResult.HasEmptySumWithVat; dto.HasInvalidSumWithoutVat = model.TotalsResult.HasInvalidSumWithoutVat; dto.HasInvalidTotalVatSum = model.TotalsResult.HasInvalidTotalVatSum; dto.HasInvalidSumWithVat = model.TotalsResult.HasInvalidSumWithVat; dto.ItemValidationResults = model.ItemResults .Select((itemDto, i) => itemDto.MapToDto(waybillId, i + 1)) .ToList(); }
public static void FillFromWaybillModel(this WaybillDto dto, Waybill model) { if (model == null) { throw new ArgumentNullException(nameof(model)); } dto.Id = model.Id.Value; dto.OrderId = model.OrderId.Value; dto.FillContentFromModel(model.Content, model.Id); }
private static GetWaybillsResult GetWaybillsResult( WaybillDto waybillDto, string fileName, DateTimeOffset uploadTime) { return(new GetWaybillsResult( waybillDto.MapToPaperWaybill(), fileName, uploadTime, waybillDto.ValidationResult?.MapToModel() )); }
private async Task <WaybillDto> CreateEmptyWaybillDto(Waybill waybill) { var dto = new WaybillDto(); await _context.Waybills.AddAsync(dto); await _context.SaveChangesAsync(); var id = new WaybillId(dto.Id); //We are setting id for further mapping waybill.SetId(id); return(dto); }
private void RemoveChildren(WaybillDto persistedDto) { if (persistedDto.Content?.Items != null) { _context.Set <WaybillItemDto>().RemoveRange(persistedDto.Content.Items); } if (persistedDto.ValidationResult?.ItemValidationResults != null) { _context.Set <WaybillItemValidationResultDto>() .RemoveRange(persistedDto.ValidationResult.ItemValidationResults); } }
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)); }