private async Task CheckoutAsync()
        {
            try
            {
                var authToken = Settings.AuthAccessToken;

                var basket = _orderService.MapOrderToBasket(Order);
                basket.RequestId = Guid.NewGuid();

                // Create basket checkout
                await _basketService.CheckoutAsync(basket, authToken);

                // Clean Basket
                await _basketService.ClearBasketAsync(_shippingAddress.Id.ToString(), authToken);

                // Reset Basket badge
                var basketViewModel = ViewModelLocator.Resolve <BasketViewModel>();
                basketViewModel.BadgeCount = 0;

                // Navigate to Orders
                await NavigationService.NavigateToAsync <MainViewModel>(new TabParameter { TabIndex = 1 });

                await NavigationService.RemoveLastFromBackStackAsync();

                // Show Dialog
                await DialogService.ShowAlertAsync("Order sent successfully!", string.Format("Order {0}", Order.OrderNumber), "Ok");

                await NavigationService.RemoveLastFromBackStackAsync();
            }
            catch
            {
                await DialogService.ShowAlertAsync("An error ocurred. Please, try again.", "Oops!", "Ok");
            }
        }
Exemplo n.º 2
0
        public async Task Test_ClearBasket()
        {
            BasketModel _basket = await _basketService.UpdateBasketItemAsync(new ItemModel { Id = 1, PricePerUnit = 400 }, 1);

            _basket = await _basketService.UpdateBasketItemAsync(new ItemModel { Id = 1, PricePerUnit = 400 }, 1);

            _basket = await _basketService.ClearBasketAsync();

            Assert.Null(_basket.Items);
            Assert.Equal(0, _basket.TotalCost);
        }
Exemplo n.º 3
0
        public async Task ClearAllBasketItem()
        {
            // Arrange
            _iRepositoryMock.Setup(m => m.GetAsync <BasketItem>(b => b.UserId == 1, null, null, null, null)).Returns(Task.FromResult(basketItemsDbSetMock.Where(b => b.UserId == 1)));

            // Act
            var result = await _iBasketService.ClearBasketAsync(1);

            // Assert
            Assert.NotNull(result);
            Assert.Equal(0, result.Count);
        }
Exemplo n.º 4
0
        public async Task <ActionResult> ClearBasketAsync()
        {
            try
            {
                await _basketService.ClearBasketAsync();

                return(Ok($"Basket cleared!"));
            }
            catch (Exception ex)
            {
                return(BadRequest($"{ex.Message} \n {ex.InnerException.Message}"));
            }
        }
Exemplo n.º 5
0
        public async Task <IActionResult> ClearBasket(int userId)
        {
            IList <BasketItem> basketItems = await _iBasketService.ClearBasketAsync(userId);

            return(Ok(basketItems));
        }
Exemplo n.º 6
0
        public async Task <ActionResult> Delete()
        {
            await _basketService.ClearBasketAsync();

            return(Ok());
        }