public async Task GetResult_NotificationNumber_Success()
        {
            A.CallTo(() => repository.GetNumber(notificationId))
            .Returns(notificationNumber);

            var result = await rule.GetResult(GetTestData(), notificationId);

            Assert.Equal(ReceiptRecoveryContentRules.WrongNotificationNumber, result.Rule);
            Assert.Equal(MessageLevel.Success, result.MessageLevel);
        }
Ejemplo n.º 2
0
        public PrenotificationNotificationNumberRuleTests()
        {
            notificationId = Guid.NewGuid();

            notificationApplicationRepository = A.Fake <INotificationApplicationRepository>();

            A.CallTo(() => notificationApplicationRepository.GetNumber(notificationId)).Returns(NotificationNumber);

            rule = new PrenotificationNotificationNumberRule(notificationApplicationRepository);
        }
        public async Task <byte[]> Generate(Guid notificationId)
        {
            using (var memoryStream = DocumentHelper.ReadDocumentStreamShared("InterimMovementMergeTemplate.docx"))
            {
                using (var document = WordprocessingDocument.Open(memoryStream, true))
                {
                    var notificationNumber = await notificationApplicationRepository.GetNumber(notificationId);

                    MergeFieldLocator.MergeNamedField("NotificationNumber", notificationNumber, document);
                }

                return(memoryStream.ToArray());
            }
        }
Ejemplo n.º 4
0
        public async Task <byte[]> GenerateBulkUploadTemplate(Guid notificationId, BulkType bulkType)
        {
            var templateName = string.Empty;

            switch (bulkType)
            {
            case BulkType.Prenotification:
                templateName = "BulkUploadPrenotificationTemplate.xlsx";
                break;

            case BulkType.ReceiptRecovery:
                templateName = "BulkUploadReceiptRecoveryTemplate.xlsx";
                break;
            }

            using (var memoryStream = DocumentHelper.ReadDocumentStreamShared(templateName))
            {
                var notificatioNumber = await notificationApplicationRepository.GetNumber(notificationId);

                using (var document = SpreadsheetDocument.Open(memoryStream, true))
                {
                    var workbookPart = document.WorkbookPart;
                    var sheet        = workbookPart.Workbook.Descendants <Sheet>().FirstOrDefault();

                    if (sheet != null)
                    {
                        var worksheetPart = workbookPart.GetPartById(sheet.Id.Value) as WorksheetPart;

                        if (worksheetPart != null)
                        {
                            var cell = GetCell(worksheetPart.Worksheet, "A", 2);

                            cell.CellValue = new CellValue(notificatioNumber);
                            cell.DataType  = new EnumValue <CellValues>(CellValues.String);

                            worksheetPart.Worksheet.Save();
                        }
                    }
                }

                return(memoryStream.ToArray());
            }
        }
Ejemplo n.º 5
0
        public async Task <ReceiptRecoveryContentRuleResult <ReceiptRecoveryContentRules> > GetResult(List <ReceiptRecoveryMovement> movements, Guid notificationId)
        {
            var notificationNumber = await notificationApplicationRepository.GetNumber(notificationId);

            return(await Task.Run(() =>
            {
                var shipments =
                    movements.Where(m => m.ShipmentNumber.HasValue && m.NotificationNumber != notificationNumber)
                    .GroupBy(x => x.ShipmentNumber)
                    .OrderBy(x => x.Key)
                    .Select(x => x.Key)
                    .ToList();

                var result = shipments.Any() ? MessageLevel.Error : MessageLevel.Success;
                var minShipment = shipments.FirstOrDefault() ?? 0;

                var shipmentNumbers = string.Join(", ", shipments);
                var errorMessage = string.Format(Prsd.Core.Helpers.EnumHelper.GetDisplayName(ReceiptRecoveryContentRules.WrongNotificationNumber), shipmentNumbers, notificationNumber);

                return new ReceiptRecoveryContentRuleResult <ReceiptRecoveryContentRules>(ReceiptRecoveryContentRules.WrongNotificationNumber, result, errorMessage, minShipment);
            }));
        }
Ejemplo n.º 6
0
 public async Task <string> HandleAsync(GetNotificationNumber message)
 {
     return(await notificationApplicationRepository.GetNumber(message.NotificationId));
 }