public void Receive(CreditResponse response)
    {
        if (response.Succeeded)
        {
            var warehouseActor = this.System.GetActorRef(
                type: "Warehouse",
                id: transactionId.Value);

            warehouseActor.Send(new ReserveItemCommand
            {
                ItemId       = this.itemId.Value,
                Quantity     = this.quantity.Value,
                AllOrNothing = true
            });
        }
        else
        {
            this.requestor.Value.Send(
                new PurchaseItemResponse
            {
                Succeeded = false,
                ErrorCode = response.ErrorCode
            });

            this.Terminate();
        }
    }
Exemplo n.º 2
0
        public ActionResult Index(CreditResponse resp)
        {
            //get values from text box using credit response
            double oldB = resp.oldBalance;
            double c    = resp.charges;
            double cr   = resp.credits;

            //apply approp. charges and update balances
            double financeCharges = oldB * 0.015;
            double newBalance     = oldB + c + financeCharges - cr;
            double minPayment;

            if (newBalance <= 20)
            {
                minPayment = newBalance;
            }
            else
            {
                minPayment = (newBalance * 0.10) + 20;
            }
            //format to currency and set view bag for display
            ViewBag.financeBag = String.Format("{0:C2}", financeCharges);
            ViewBag.balanceBag = String.Format("{0:C2}", newBalance);
            ViewBag.minBag     = String.Format("{0:C2}", minPayment);

            return(View());
        }
Exemplo n.º 3
0
        public async System.Threading.Tasks.Task CreditNewRow_Should_Serialize_AsExpected()
        {
            // Arrange
            var creditResponseObject   = JsonConvert.DeserializeObject <CreditResponseObject>(DataSample.CreditResponse, JsonSerialization.Settings);
            var expectedTask           = JsonConvert.DeserializeObject <Task>(DataSample.TaskResponse, JsonSerialization.Settings);
            var expectedCreditResponse = new CreditResponse(creditResponseObject);
            var sveaClient             = SveaClient(CreateHandlerMockWithAction(DataSample.AdminDeliveredOrder, "", expectedTask.ResourceUri.OriginalString, DataSample.TaskResponse, DataSample.CreditResponse));

            // Act
            var order = await sveaClient.PaymentAdmin.GetOrder(2291662);

            var delivery         = order.Deliveries.FirstOrDefault(dlv => dlv.Id == 5588817);
            var orderRowIds      = delivery.OrderRows.Where(row => row.AvailableActions.Contains(OrderRowActionType.CanCreditRow)).Select(row => (long)row.OrderRowId).ToList();
            var resourceResponse = await delivery.Actions.CreditNewRow(new CreditNewOrderRowRequest(
                                                                           new CreditOrderRow(
                                                                               name: "Slim Fit 512",
                                                                               MinorUnit.FromDecimal(100),
                                                                               MinorUnit.FromDecimal(12)
                                                                               )
                                                                           ));

            // Assert
            Assert.Equal(expectedTask.ResourceUri.OriginalString, resourceResponse.TaskUri.OriginalString);
            Assert.True(DataComparison.CreditResponsesAreEqual(expectedCreditResponse, resourceResponse.Resource));
        }
Exemplo n.º 4
0
        public async Task CreditFull_ServiceReturnsValidJson_ReturnsResponseInstance()
        {
            _messageHandler.SendAsyncReturns(new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent("{\"totalCapturedAmount\": 248.0000,\"totalAuthorizedAmount\": 248.0000,\"refundNumbers\": [\"800007902\"]}")
            });
            CreditResponse result = await _service.CreditFullAsync(Factory.GetString(), Factory.GetString());

            Assert.IsType <CreditResponse>(result);
        }
Exemplo n.º 5
0
        public static bool CreditResponsesAreEqual(CreditResponse expectedResponse, CreditResponse actualResponse)
        {
            Assert.Equal(expectedResponse.CreditId, actualResponse.CreditId);

            return(true);
        }