public async Task <CreateOrderResponse> CreateOrder( string urlBase, string accessToken, int address, CartDataService listCart ) { try { var request = JsonConvert.SerializeObject(listCart); var content = new StringContent( request, Encoding.UTF8, "application/json"); var client = new HttpClient(); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken); client.BaseAddress = new Uri(urlBase); var response = await client.PostAsync("/api/products/create-order/address/" + address, content); var resultJSON = await response.Content.ReadAsStringAsync(); var result = JsonConvert.DeserializeObject <CreateOrderResponse>(resultJSON); return(result); } catch { return(null); } }
// { "tokenData" , "oGeDb2sML1YU8EcNOKsLHurG/H86MFoAws/cb7+1FUY="}, #region Constructor public CheckoutPageViewModel(ProfileDataService userDataService, CartDataService cartDataService, CatalogDataService catalogDataService) { ButtonActive = true; this.userDataService = userDataService; this.cartDataService = cartDataService; this.catalogDataService = catalogDataService; var app = Application.Current as App; DeliveryAddress = new ObservableCollection <Address>(); PaymentModes = new ObservableCollection <Payment>(); MinimumOrderAmount = (double)app.MinimumOrderAmount; Device.BeginInvokeOnMainThread(() => { FetchPaymentOptions(); FetchCartList(); GetPaymentAndPriceMessage(); GetPaymentCredentials(); CheckLocationPermissions(); }); EditCommand = new Command(EditClicked); AddAddressCommand = new Command(AddAddressClicked); PlaceOrderCommand = new Command(PlaceOrderClicked); PaymentOptionCommand = new Command(PaymentOptionClicked); ApplyCouponCommand = new Command(ApplyCouponClicked); AddressChanged = new Command(addressChangedClicked); DeliveryOptionCommand = new Command(GetSelectedDeliveryAddressId); StateChangedCommand = new Command(GetSelectedPaymentOption); //Task.Run(() => CheckLocationPermissions()); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // Create your application here SetContentView(Resource.Layout.CartView); _cartDataService = new CartDataService(); _cartListView = FindViewById <ListView>(Resource.Id.cartListView); _cartItems = _cartDataService.GetCart().CartItems; _cartListView.Adapter = new CartAdapter(this, _cartItems); }
private async void CalculateDelivery() { var connection = await this.apiService.CheckConnection(); if (!connection.IsSuccess) { await Application.Current.MainPage.DisplayAlert( "Error", connection.Message, "Aceptar"); return; } var mainViewModel = MainViewModel.GetInstance(); var data = new CartDataService(); data.Products = mainViewModel.CartList; var response = await this.apiService.CalculateDelivery( "https://thenuap.com", mainViewModel.User.api_token, data); if (response == null) { await Application.Current.MainPage.DisplayAlert( "Error", "Ha ocurrido un error", "Aceptar"); return; } if (response.Errors != null) { await Application.Current.MainPage.DisplayAlert( "Error", response.Errors.First().Detail, "Aceptar"); return; } this.Delivery = response.Data.Discount; }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.CartView); cartDataService = new CartDataService(); FindViews(); cartItems = cartDataService.GetCart().CartItems; cartListView.Adapter = new CartAdapter(this, cartItems); BindData(); HandleEvents(); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.CartView); cartDataService = new CartDataService(); cartListView = FindViewById <ListView>(Resource.Id.cartListView); var orderButton = FindViewById <Button>(Resource.Id.placeOrderButton); orderButton.Click += OrderButton_Click; cartItems = cartDataService.GetCart().CartItems; cartListView.Adapter = new CartAdapter(this, cartItems); }
public CartViewPage() { InitializeComponent(); cartDataService = new CartDataService(); Items = new ObservableCollection <Models.CartItem>(); MyListView.ItemsSource = cartDataService.GetCart().CartItems; MyListView.HasUnevenRows = true; TotalLabel.Text = cartDataService.GetCartTotal().ToString("C2"); CheckoutButton.Clicked += CheckoutButton_Clicked; ContinueOrderingButton.Clicked += ContinueOrderingButton_Clicked; }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.CheckoutView); dataService = new CartDataService(); FindViews(); BindData(); HandleEvents(); Spinner stateSpinner = FindViewById <Spinner>(Resource.Id.stateSpinner); var adapter = new ArrayAdapter <string>(this, Resource.Layout.list_item, ResourceHelper.StateList); stateSpinner.Adapter = adapter; }
private void RegisterIoc(IServiceCollection services) { services.AddSingleton <IContextFactory>(new ContextFactory()); var productDataService = new ProductDataService(); services.AddSingleton <IProductObservable>(productDataService); services.AddSingleton <IProductDataService>(productDataService); services.AddSingleton <IProductDbService, ProductDbService>(); services.AddSingleton <IProductPublishService, ProductPublishService>(); var cartDataService = new CartDataService(); services.AddSingleton <ICartObservable>(cartDataService); services.AddSingleton <ICartDataService>(cartDataService); services.AddSingleton <ICartDbService, CartDbService>(); services.AddSingleton <ICartPublishService, CartPublishService>(); }
public CartDataSource() { cartDataService = new CartDataService(); cartItems = cartDataService.GetCart().CartItems; }
public void AddToCart(Deal deal, int amount) { CartDataService cartDataService = new CartDataService(); cartDataService.AddCartItem(deal, amount); }
public void AddToCart(Pho pho, int amount) { CartDataService cartDataService = new CartDataService(); cartDataService.AddCartItem(pho, amount); }
private void AddToCart(Models.MenuItem item, int amount, double price) { CartDataService cartDataService = new CartDataService(); cartDataService.AddCartItem(item, amount, price); }
private void OnAddToCart(object obj) { CartDataService.AddCartItem(SelectedBurger, Amount); }
public void AddToCart(HotDog hotDog, int amount) { CartDataService cartDataService = new CartDataService(); cartDataService.AddCartItem(hotDog, amount); }
private async void CreateOrder() { var connection = await this.apiService.CheckConnection(); if (!connection.IsSuccess) { await Application.Current.MainPage.DisplayAlert( "Error", connection.Message, "Aceptar"); return; } var mainViewModel = MainViewModel.GetInstance(); var data = new CartDataService(); data.Products = mainViewModel.CartList; var response = await this.apiService.CreateOrder( "https://thenuap.com", mainViewModel.User.api_token, 19, data); if (response == null) { await Application.Current.MainPage.DisplayAlert( "Error", "Ha ocurrido un error", "Aceptar"); return; } if (response.Errors != null) { await Application.Current.MainPage.DisplayAlert( "Error", response.Errors.First().Detail, "Aceptar"); return; } List <int> orders = response.Data.Orders; string url = "https://thenuap.com/payment-gateway?"; string user = "******" + mainViewModel.User.id; int count = 0; foreach (var item in orders) { url += "orders[" + count + "]=" + item + "&"; count++; } url += user; mainViewModel.PaymentGateway = new PaymentGatewayViewModel(url); await Application.Current.MainPage.Navigation.PushAsync(new PaymentGatewayPage()); }
private void InitializeData() { CartItems = CartDataService.GetCart().CartItems.ToObservableCollection(); }