/// <summary> /// Issues the voucher. /// </summary> /// <param name="voucherId">The voucher identifier.</param> /// <param name="operatorId">The operator identifier.</param> /// <param name="estateId">The estate identifier.</param> /// <param name="transactionId">The transaction identifier.</param> /// <param name="issuedDateTime">The issued date time.</param> /// <param name="value">The value.</param> /// <param name="recipientEmail">The recipient email.</param> /// <param name="recipientMobile">The recipient mobile.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns></returns> public async Task <IssueVoucherResponse> IssueVoucher(Guid voucherId, String operatorId, Guid estateId, Guid transactionId, DateTime issuedDateTime, Decimal value, String recipientEmail, String recipientMobile, CancellationToken cancellationToken) { await this.ValidateVoucherIssue(estateId, operatorId, cancellationToken); VoucherAggregate voucher = await this.VoucherAggregateRepository.GetLatestVersion(voucherId, cancellationToken); voucher.Generate(operatorId, estateId, transactionId, issuedDateTime, value); var voucherModel = voucher.GetVoucher(); // Generate the barcode Barcode barcode = new Barcode(voucherModel.VoucherCode); voucher.AddBarcode(barcode.GetBase64Image()); voucher.Issue(recipientEmail, recipientMobile, issuedDateTime); await this.VoucherAggregateRepository.SaveChanges(voucher, cancellationToken); return(new IssueVoucherResponse { ExpiryDate = voucherModel.ExpiryDate, Message = voucherModel.Message, VoucherCode = voucherModel.VoucherCode, VoucherId = voucherId }); }
public void VoucherAggregate_AddBarcode_VoucherNotGenerated_ErrorThrown() { VoucherAggregate aggregate = VoucherAggregate.Create(TestData.VoucherId); Should.Throw <InvalidOperationException>(() => { aggregate.AddBarcode(TestData.Barcode); }); }
public static VoucherAggregate GetVoucherAggregateWithRecipientMobile() { VoucherAggregate aggregate = VoucherAggregate.Create(TestData.VoucherId); aggregate.Generate(TestData.OperatorIdentifier, TestData.EstateId, TestData.TransactionId, TestData.GeneratedDateTime, TestData.Value); aggregate.AddBarcode(TestData.Barcode); aggregate.Issue(null, TestData.RecipientMobile, TestData.IssuedDateTime); return(aggregate); }
public void VoucherAggregate_AddBarcode_BarcodeIsAdded() { VoucherAggregate aggregate = VoucherAggregate.Create(TestData.VoucherId); aggregate.Generate(TestData.OperatorIdentifier, TestData.EstateId, TestData.TransactionId, TestData.GeneratedDateTime, TestData.Value); aggregate.AddBarcode(TestData.Barcode); var voucher = aggregate.GetVoucher(); voucher.Barcode.ShouldBe(TestData.Barcode); }
public void VoucherAggregate_AddBarcode_InvalidBarcode_ErrorThrown(String barcode) { VoucherAggregate aggregate = VoucherAggregate.Create(TestData.VoucherId); aggregate.Generate(TestData.OperatorIdentifier, TestData.EstateId, TestData.TransactionId, TestData.GeneratedDateTime, TestData.Value); Should.Throw <ArgumentException>(() => { aggregate.AddBarcode(barcode); }); }