private async Task UpdateValues() { ISharedPreferences prefs = PreferenceManager.GetDefaultSharedPreferences(this); int Counter = 0; mAdapter.AddSectionHeaderItem("Incomplete Orders"); var Unpaid = await api.GetPendingOrdersByReason("unpaid"); var NotShipped = await api.GetPendingOrdersByReason("not shipped"); var PendingCount = await api.GetPendingOrdersCount(); var Currency = await api.GetCurrency(); mAdapter.AddItem("Unpaid: " + Unpaid.ToString("0.0#") + " " + Currency); mAdapter.AddItem("Not Yet Shipped: " + NotShipped.ToString("0.0#") + " " + Currency); mAdapter.AddItem("Pending Count: " + PendingCount); mAdapter.AddSectionHeaderItem("Bestsellers (Quantity)"); var BestQuantity = await api.GetBestsellerByQuantity(); foreach (BestsellerDTO elem in BestQuantity) { if (Counter != prefs.GetInt("bestsellers_quantity", 5) - 1) { mAdapter.AddItem(elem.Product.Name); } else { break; } Counter++; } mAdapter.AddSectionHeaderItem("Bestsellers (Amount)"); Counter = 0; var BestAmount = await api.GetBestsellerByAmount(); foreach (BestsellerDTO elem in BestAmount) { if (Counter != prefs.GetInt("bestsellers_amount", 5) - 1) { mAdapter.AddItem(elem.Product.Name); } else { break; } Counter++; } dialog.Dismiss(); }
private async Task InitializePage() { var UnpaidVal = await api.GetPendingOrdersByReason("unpaid"); var NotShippedVal = await api.GetPendingOrdersByReason("not shipped"); var PendingCountVal = await api.GetPendingOrdersCount(); var Currency = await api.GetCurrency(); Unpaid.Text = UnpaidVal.ToString("0.0#") + " " + Currency; NotShipped.Text = NotShippedVal.ToString("0.0#") + " " + Currency; PendingCount.Text = PendingCountVal.ToString(); var BestsellersQuantityArray = await api.GetBestsellerByQuantity(); var BestsellersAmountArray = await api.GetBestsellerByAmount(); var QuantityList = new List <BestsellerData>(); var BestQuantity = settings.GetValueOrDefault(SaleVQuantity, 5); var Counter = 0; foreach (BestsellerDTO prod in BestsellersQuantityArray) { if (Counter == BestQuantity) { break; } QuantityList.Add(new BestsellerData { Image = ConvertToBitmapImage(prod.Product.Image.First()), QuantityOrAmount = prod.Quantity.ToString(), ProductName = prod.Product.Name }); Counter++; } BestsellersQuantity.ItemsSource = QuantityList; LoadingQuantityHolder.Visibility = System.Windows.Visibility.Collapsed; var AmountList = new List <BestsellerData>(); var BestAmount = settings.GetValueOrDefault(SaleVQuantity, 5); Counter = 0; foreach (BestsellerDTO prod in BestsellersAmountArray) { if (Counter == BestAmount) { break; } AmountList.Add(new BestsellerData { Image = ConvertToBitmapImage(prod.Product.Image.First()), QuantityOrAmount = prod.Amount.ToString("0.#") + " " + await api.GetCurrency(), ProductName = prod.Product.Name }); Counter++; } BestsellersAmount.ItemsSource = AmountList; LoadingAmountHolder.Visibility = System.Windows.Visibility.Collapsed; }
private async void InitializeMainPages() { string Current = ""; UserSettings.TryGetValue("current_user", out Current); var tmp = await api.GetCustomersByEmail(Current); Currency = await api.GetCurrency(); Customer = tmp.First(); CustomerName.Text = Customer.FullName; var Featured = await api.FeaturedProducts(); FeaturedCount = Featured.Count(); var FeaturedList = new List <ProductData>(); int FeatCount = Helper.GetSetting <int>("featured_count"); int tmpCount = 0; foreach (ProductDTO p in Featured) { if (tmpCount == FeatCount) { break; } FeaturedList.Add(new ProductData { Id = p.Id, ProductName = p.Name, Description = p.Description, Image = Helper.ConvertToBitmapImage(p.Image.First()), Value = p.Price.ToString("0") + " " + Currency }); tmpCount++; } FeaturedProducts.ItemsSource = FeaturedList; var BestsellersA = await api.GetBestsellerByAmount(); var BestsellersQ = await api.GetBestsellerByQuantity(); var Bests = new List <ProductData>(); var BestCount = Helper.GetSetting <int>("bestsellers_count") / 2; for (int i = 0; i < BestCount; i++) { if (i < BestsellersA.Count()) { Bests.Add(new ProductData { Id = BestsellersA[i].Product.Id, ProductName = BestsellersA[i].Product.Name, Value = BestsellersA[i].Product.Price.ToString("0.#") + " " + Currency, Image = Helper.ConvertToBitmapImage(BestsellersA[i].Product.Image.First()) }); } if (i < BestsellersQ.Count()) { Bests.Add(new ProductData { Id = BestsellersQ[i].Product.Id, ProductName = BestsellersQ[i].Product.Name, Value = BestsellersQ[i].Product.Price.ToString("0.#") + " " + Currency, Image = Helper.ConvertToBitmapImage(BestsellersQ[i].Product.Image.First()) }); } } BestsellersList.ItemsSource = Bests; var Categories = await api.GetMainCategories(); var CategoriesList = new List <CategoryData>(); foreach (CategoryDTO c in Categories) { CategoriesList.Add(new CategoryData { Id = c.Id, Name = c.Name, Image = Helper.ConvertToBitmapImage(c.Image) }); } CategoriesListbox.ItemsSource = CategoriesList; HideLoading(); }
private async Task InitializeStore() { var Current = ""; if (ChangeStore) { ResetValues(); UserSettings.Remove("current_url"); UserSettings.Add("current_url", StoreUrl); UserSettings.Remove("current_user"); UserSettings.Add("current_user", UserName); } UserSettings.TryGetValue("current_user", out Current); SideMenu.Header = await api.GetStoreName(); SideMenu.Header = SideMenu.Header.ToString().ToLower(); AdminName.Text = await api.GetFullName(Current); if (!ChangeStore) { foreach (KeyValuePair <string, object> url in UserSettings) { if (url.Key.StartsWith("store_url_")) { var Name = url.Key.Substring(10); UrlsMap.Add(new KeyValuePair <String, String>(Name, (string)url.Value)); urls.Add(Name); } } MyStoresList.ItemsSource = urls; } var Currency = await api.GetCurrency(); var SaleValuesIn = settings.GetValueOrDefault <int>(SaleValuesDash, 0); var PendingV = await api.GetStats(3); var CompleteV = await api.GetStats(2); var CancelledV = await api.GetStats(1); if (SaleValuesIn == 0) { PendingSales.Text = PendingV + " " + Currency;; CompleteSales.Text = CompleteV + " " + Currency;; CancelledSales.Text = CancelledV + " " + Currency;; } else { PendingSales.Text = PendingV.ToString("0.0#") + " " + Currency;; CompleteSales.Text = CompleteV.ToString("0.0#") + " " + Currency;; CancelledSales.Text = CancelledV.ToString("0.0#") + " " + Currency;; } var PendingOrdersCount = await api.GetPendingOrdersCount(); var CartsCount = await api.GetCartsCount(); var WishlistCount = await api.GetWishlistCount(); PendingOrders.Text = PendingOrdersCount.ToString(); Carts.Text = CartsCount.ToString(); Wishlists.Text = WishlistCount.ToString(); var VisitorsCount = await api.GetOnlineCount(); var RegisteredCount = await api.GetRegisteredCustomersCount(); var VendorsCount = await api.GetVendorsCount(); Visitors.Text = VisitorsCount.ToString(); Registered.Text = RegisteredCount.ToString(); Vendors.Text = VendorsCount.ToString(); var NPopWords = settings.GetValueOrDefault <int>(KeywordsInDash, 3); var PopularWords = await api.GetPopularKeywords(NPopWords); WordsHolder.Children.Clear(); foreach (KeywordDTO word in PopularWords) { var Sp = new StackPanel(); var WordBlock = new TextBlock(); WordBlock.Text = word.Keyword; WordBlock.FontSize = 20; Sp.Background = new SolidColorBrush(Colors.Gray); WordBlock.Margin = new System.Windows.Thickness { Left = 5, Right = 5 }; Sp.HorizontalAlignment = System.Windows.HorizontalAlignment.Center; Sp.VerticalAlignment = System.Windows.VerticalAlignment.Center; Sp.Margin = new System.Windows.Thickness { Left = 5 }; Sp.Children.Add(WordBlock); WordsHolder.Children.Add(Sp); } var BestAmount = await api.GetBestsellerByAmount(); BestsellerAmount.Text = BestAmount.First().Product.Name; var BestQuantity = await api.GetBestsellerByQuantity(); BestsellerQuantity.Text = BestQuantity.First().Product.Name; var WeekCustomers = await api.GetCustomerCountByTime(7); var TwoWeeksCustomers = await api.GetCustomerCountByTime(14); var MonthCustomers = await api.GetCustomerCountByTime(30); var YearCustomers = await api.GetCustomerCountByTime(365); var registered = new int[4] { WeekCustomers, TwoWeeksCustomers, MonthCustomers, YearCustomers }; RegisteredUsersGraph Graph = new RegisteredUsersGraph(registered, true); RegisteredPlot.Model = Graph.MyModel; ChangeStore = false; }
private async Task UpdateValues(NopCore api) { ISharedPreferences prefs = PreferenceManager.GetDefaultSharedPreferences(this); var PendingV = FindViewById <TextView>(Resource.Id.pending); var CompleteV = FindViewById <TextView>(Resource.Id.complete); var CancelledV = FindViewById <TextView>(Resource.Id.cancelled); var PendingCountV = FindViewById <TextView>(Resource.Id.pendingorders); var CartsCountV = FindViewById <TextView>(Resource.Id.carts); var WishlistCountV = FindViewById <TextView>(Resource.Id.wishlists); var RegisteredV = FindViewById <TextView>(Resource.Id.registered); var OnlineV = FindViewById <TextView>(Resource.Id.online); var VendorsV = FindViewById <TextView>(Resource.Id.vendors); var BestsellerQV = FindViewById <TextView>(Resource.Id.bestsellersquantity); var BestsellerAV = FindViewById <TextView>(Resource.Id.bestsellersamount); var KeywordsLoadingV = FindViewById <TextView>(Resource.Id.keywords); var KeywordsLayoutHolder = FindViewById <LinearLayout>(Resource.Id.wordlayout); var Complete = await api.GetStats(2); var Pending = await api.GetStats(3); var Cancelled = await api.GetStats(1); var Currency = await api.GetCurrency(); if (prefs.GetString("sales_format", "Integer").Equals("Integer")) { PendingV.Text = Pending.ToString("0") + " " + Currency; CompleteV.Text = Complete.ToString("0") + " " + Currency; CancelledV.Text = Cancelled.ToString("0") + " " + Currency; } else { PendingV.Text = Pending.ToString("0.0#") + " " + Currency; CompleteV.Text = Complete.ToString("0.0#") + " " + Currency; CancelledV.Text = Cancelled.ToString("0.0#") + " " + Currency; } var PendingCount = await api.GetPendingOrdersCount(); var CartsCount = await api.GetCartsCount(); var WishlistCount = await api.GetWishlistCount(); PendingCountV.Text = PendingCount.ToString(); CartsCountV.Text = CartsCount.ToString(); WishlistCountV.Text = WishlistCount.ToString(); var Registered = await api.GetRegisteredCustomersCount(); var Online = await api.GetOnlineCount(); var Vendors = await api.GetVendorsCount(); RegisteredV.Text = Registered.ToString(); OnlineV.Text = Online.ToString(); VendorsV.Text = Vendors.ToString(); var Keywords = await api.GetPopularKeywords(3); var BestsellerQ = await api.GetBestsellerByQuantity(); var BestsellerA = await api.GetBestsellerByAmount(); int wordSpace = DensityPixel(2); KeywordsLayoutHolder.RemoveAllViews(); for (int i = 0; i < prefs.GetInt("keywords_dashboard", 3); i++) { LinearLayout WordHolder = new LinearLayout(this); LinearLayout.LayoutParams WordLayout = (LinearLayout.LayoutParams)KeywordsLayoutHolder.LayoutParameters; WordHolder.Orientation = Orientation.Horizontal; var WHParams = WordLayout; WHParams.SetMargins(0, 0, wordSpace, 0); WordHolder.LayoutParameters = WHParams; TextView word = new TextView(this); word.Text = Keywords[i].Keyword; word.SetBackgroundDrawable(Resources.GetDrawable(Resource.Drawable.keyword_holder_bg)); word.SetTextColor(Resources.GetColor(Resource.Color.white)); word.SetPadding(wordSpace, wordSpace, wordSpace, wordSpace); word.SetSingleLine(); WordHolder.AddView(word); KeywordsLayoutHolder.AddView(WordHolder); } BestsellerAV.Text = BestsellerA[0].Product.Name; BestsellerQV.Text = BestsellerQ[0].Product.Name; var WeekCustomers = await api.GetCustomerCountByTime(7); var TwoWeeksCustomers = await api.GetCustomerCountByTime(14); var MonthCustomers = await api.GetCustomerCountByTime(30); var YearCustomers = await api.GetCustomerCountByTime(365); var registered = new int [4] { WeekCustomers, TwoWeeksCustomers, MonthCustomers, YearCustomers }; RegisteredUsersGraph Graph = new RegisteredUsersGraph(registered, false); var plotView = FindViewById <PlotView>(Resource.Id.plotView_Temp); plotView.Model = Graph.MyModel; dialog.Dismiss(); }