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");
            }
        }
Esempio n. 2
0
        public async Task <IActionResult> Checkout(CheckoutDTO dto)
        {
            var basketId = GetBasketId();

            if (basketId == null)
            {
                return(BadRequest());
            }

            using var uow = _unitOfWorkFactory.Create();

            await _basketService.CheckoutAsync(
                basketId.Value,
                dto.FirstName,
                dto.LastName,
                dto.EmailAddress,
                dto.PhoneNumber,
                dto.City,
                dto.AddressLine1,
                dto.AddressLine2,
                dto.ZipCode);

            uow.Commit();

            return(NoContent());
        }
Esempio n. 3
0
        public async Task <IActionResult> Checkout(Registration registration)
        {
            if (ModelState.IsValid)
            {
                var viewModel = new RegistrationViewModel(registration);
                await basketService.CheckoutAsync(GetUserId(), viewModel);

                return(RedirectToAction("Checkout"));
            }
            return(RedirectToAction("Index", "Registration"));
        }