private void UpdateListContent() { _ptotalPrice = 0; _expandedGroups = new ObservableCollection <CartViewModel>(); var _products = App.Database.GetAllProduct(); foreach (var group in _products) { _ptotalPrice += Convert.ToDouble(group.productPrice); CartViewModel newGroup = new CartViewModel(group.productName, group.productQty, group.productPrice, Convert.ToString(group.ID), group.productId, group.productCategory, group.productImage, Convert.ToString(group.ID)); var _addons = App.Database.GetAllProductAddon(Convert.ToString(group.ID)); foreach (var food in _addons) { _ptotalPrice += Convert.ToDouble(food.AddonPrice); newGroup.Add(new CartProduct { Name = food.AddonName, AddonCategory = food.AddonCategory, AddonId = food.AddonId, AddonPrice = food.AddonPrice, AddonQty = food.AddonQty, PSQLId = food.productId, ProductId = food.productId }); } _expandedGroups.Add(newGroup); } GroupedView.ItemsSource = _expandedGroups; if (_expandedGroups.Count == 0) { emptyCartLbl.IsVisible = true; totalLyt.IsVisible = false; } else { emptyCartLbl.IsVisible = false; totalLyt.IsVisible = true; totalPrice.Text = "Riyal " + _ptotalPrice; } }
public async void load() { try { if (!CommonLib.checkconnection()) { await App.Current.MainPage.Navigation.PushPopupAsync(new ShowMessage(AppResources._connection)); await Task.Delay(1000); ShowMessage.CloseAllPopup(); return; } await App.Current.MainPage.Navigation.PushPopupAsync(new Loader()); LoggedInUser objUser = App.Database.GetLoggedInUser(); string postData = "order_id=" + id; var result = await CommonLib.GetCustomerOrderInfo(CommonLib.ws_MainUrl + "getUserOrderInfo?" + postData); if (result.status == 1) { _ptotalPrice = 0; _expandedGroups = new ObservableCollection <CartViewModel>(); var _products = App.Database.GetAllProduct(); foreach (var group in result.data.order.OrderProduct) { _ptotalPrice += Convert.ToDouble(group.price) * Convert.ToDouble(group.quantity); string img = ""; foreach (var food in group.Addon) { if (food.AddonMedia == null) { img = "product_Placeholder.png"; } else { img = string.IsNullOrEmpty(food.AddonMedia.media) ? "product_Placeholder.png" : CommonLib.img_MainUrl + food.AddonMedia.media; } } CartViewModel newGroup = new CartViewModel(group.name, group.quantity, group.price, Convert.ToString(group.id), group.product_id, "", img, ""); foreach (var food in group.Addon) { _ptotalPrice += Convert.ToDouble(food.price) * Convert.ToDouble(food.quantity); newGroup.Add(new CartProduct { Note = (!string.IsNullOrEmpty(food.note)) ? AppResources.noteDetails + ":- " + food.note : "", Name = food.name, AddonCategory = "", AddonId = food.addon_id, AddonPrice = food.price, AddonQty = food.quantity, PSQLId = "", ProductId = food.product_id }); } _expandedGroups.Add(newGroup); } GroupedView.ItemsSource = _expandedGroups; if (_expandedGroups.Count == 0) { emptyCartLbl.IsVisible = true; totalLyt.IsVisible = false; } else { emptyCartLbl.IsVisible = false; totalLyt.IsVisible = true; totalPrice.Text = "Riyal " + _ptotalPrice; } // if (result.data.order.Order.status == "0") { acptBtns.IsVisible = true; statusBtns.IsVisible = false; completeLbl.IsVisible = false; deliverLbl.IsVisible = false; } if (result.data.order.Order.status != "0") { acptBtns.IsVisible = false; statusBtns.IsVisible = true; completeLbl.IsVisible = false; deliverLbl.IsVisible = false; } // string sts = ""; if (result.data.order.Order.status == "2") { sts = AppResources.Orderrejectedby; completeLbl.IsVisible = false; deliverLbl.IsVisible = false; } if (result.data.order.Order.status == "3") { sts = AppResources.Orderassignedtodriver; completeLbl.IsVisible = false; deliverLbl.IsVisible = false; } if (result.data.order.Order.status == "-1" || result.data.order.Order.status == "-2" || result.data.order.Order.status == "-3") { sts = AppResources.Ordercancel; completeLbl.IsVisible = false; deliverLbl.IsVisible = false; } if (result.data.order.Order.status == "4") { sts = AppResources.Orderacceptedbydriver; completeLbl.IsVisible = false; deliverLbl.IsVisible = false;//true; } if (result.data.order.Order.status == "5") { sts = AppResources.Orderrejectedbydriver; completeLbl.IsVisible = false; deliverLbl.IsVisible = false; } if (result.data.order.Order.status == "6") { sts = AppResources.delivered; completeLbl.IsVisible = false; deliverLbl.IsVisible = false; } if (result.data.order.Order.status == "7") { sts = AppResources.Ordercompleted1; completeLbl.IsVisible = false; deliverLbl.IsVisible = false; } if (result.data.order.Order.status == "8") { sts = AppResources.Orderacceptedbyseller; completeLbl.IsVisible = true; deliverLbl.IsVisible = false; } if (result.data.order.Order.status == "9") { sts = AppResources.delivered; if (result.data.order.Order.self_pick == "1") { completeLbl.IsVisible = true; } else { completeLbl.IsVisible = false; } deliverLbl.IsVisible = false; } statusLbl.Text = sts; Loader.CloseAllPopup(); CustomerPhone = result.data.order.Customer.phone; customerName.Text = result.data.order.Customer.first_name + " " + result.data.order.Customer.last_name; customerImage.Source = CommonLib.img_MainUrl + result.data.order.Customer.image; } else { Loader.CloseAllPopup(); if (App.Lng == "ar-AE") { await App.Current.MainPage.Navigation.PushPopupAsync(new ShowMessage(result.msg_ar)); } else { await App.Current.MainPage.Navigation.PushPopupAsync(new ShowMessage(result.msg_en)); } await Task.Delay(1000); ShowMessage.CloseAllPopup(); } } catch (Exception ex) { Loader.CloseAllPopup(); } }
public async void load() { try { if (!CommonLib.checkconnection()) { await App.Current.MainPage.Navigation.PushPopupAsync(new ShowMessage(AppResources._connection)); await Task.Delay(1000); ShowMessage.CloseAllPopup(); return; } await App.Current.MainPage.Navigation.PushPopupAsync(new Loader()); LoggedInUser objUser = App.Database.GetLoggedInUser(); string postData = "order_id=" + id; var result = await CommonLib.GetCustomerOrderInfo(CommonLib.ws_MainUrl + "getUserOrderInfo?" + postData); if (result.status == 1) { // DateTime order = Convert.ToDateTime(result.data.order.Order.created).AddMinutes(5); DateTime server = Convert.ToDateTime(result.data.server_time); string sts = ""; if (result.data.order.Order.status == "0") { sts = AppResources.Ordercreated; img1.Source = "checked.png"; img2.Source = "twoImg.png"; img3.Source = "threeImg.png"; img4.Source = "fourImg.png"; if (order > server) { if (result.data.order.Order.payment_method == "1") { cancelLbl.IsVisible = true; } } else { cancelLbl.IsVisible = false; } } if (result.data.order.Order.status == "1") { sts = AppResources.Orderacceptedbyseller; img1.Source = "checked.png"; img2.Source = "checked.png"; img3.Source = "threeImg.png"; img4.Source = "fourImg.png"; if (order > server) { if (result.data.order.Order.payment_method == "1") { cancelLbl.IsVisible = true; } } else { cancelLbl.IsVisible = false; } } if (result.data.order.Order.status == "2") { sts = AppResources.Orderrejectedby; img1.Source = "oneImg.png"; img2.Source = "twoImg.png"; img3.Source = "threeImg.png"; img4.Source = "fourImg.png"; cancelLbl.IsVisible = false; } if (result.data.order.Order.status == "3") { sts = AppResources.Orderassignedtodriver; img1.Source = "checked.png"; img2.Source = "checked.png"; img3.Source = "threeImg.png"; img4.Source = "fourImg.png"; if (order > server) { if (result.data.order.Order.payment_method == "1") { cancelLbl.IsVisible = true; } } else { cancelLbl.IsVisible = false; } } if (result.data.order.Order.status == "-1" || result.data.order.Order.status == "-2" || result.data.order.Order.status == "-3" || result.data.order.Order.status == "-4") { sts = AppResources.Ordercancel; img1.Source = "oneImg.png"; img2.Source = "twoImg.png"; img3.Source = "threeImg.png"; img4.Source = "fourImg.png"; cancelLbl.IsVisible = false; } if (result.data.order.Order.status == "4") { sts = AppResources.Orderacceptedbydriver; img1.Source = "checked.png"; img2.Source = "checked.png"; img3.Source = "threeImg.png"; img4.Source = "fourImg.png"; if (order > server) { if (result.data.order.Order.payment_method == "1") { cancelLbl.IsVisible = true; } } else { cancelLbl.IsVisible = false; } } if (result.data.order.Order.status == "5") { sts = AppResources.Orderrejectedbydriver; img1.Source = "oneImg.png"; img2.Source = "twoImg.png"; img3.Source = "threeImg.png"; img4.Source = "fourImg.png"; cancelLbl.IsVisible = false; } if (result.data.order.Order.status == "6") { sts = AppResources.Driveronway; trackLbl.IsVisible = true; img1.Source = "checked.png"; img2.Source = "checked.png"; img3.Source = "checked.png"; img4.Source = "fourImg.png"; cancelLbl.IsVisible = false; } if (result.data.order.Order.status == "9") { sts = AppResources.delivered; img1.Source = "checked.png"; img2.Source = "checked.png"; img3.Source = "checked.png"; img4.Source = "lastChecked.png"; cancelLbl.IsVisible = false; trackLbl.IsVisible = false; } if (result.data.order.Order.status == "7") { sts = AppResources.Ordercompleted1; img1.Source = "checked.png"; img2.Source = "checked.png"; img3.Source = "checked.png"; img4.Source = "lastChecked.png"; cancelLbl.IsVisible = false; } if (result.data.order.Order.status == "8") { sts = AppResources.Orderacceptedbyseller; trackLbl.IsVisible = true; img1.Source = "checked.png"; img2.Source = "checked.png"; img3.Source = "threeImg.png"; img4.Source = "fourImg.png"; cancelLbl.IsVisible = false; } statusLbl.Text = sts; MapPage.PickUpLatitude = result.data.order.Driver.lat; MapPage.PickUpLongitude = result.data.order.Driver.lng; MapPage.DriverImage = result.data.order.Driver.image; MapPage.DriverPhone = result.data.order.Driver.phone; MapPage.DriverName = result.data.order.Driver.first_name + " " + result.data.order.Driver.last_name; MapPage.DestinationLatitude = result.data.order.OrderAddress.lat; MapPage.DestinationLongitude = result.data.order.OrderAddress.lng; MapPage.ShopLatitude = result.data.order.Shop.latitude; MapPage.ShopLongitude = result.data.order.Shop.longitude; MapPage.ShopName = result.data.order.Shop.company_name; Device.StartTimer(TimeSpan.FromSeconds(10), () => { Update(); return(true); }); _ptotalPrice = 0; _expandedGroups = new ObservableCollection <CartViewModel>(); var _products = App.Database.GetAllProduct(); foreach (var group in result.data.order.OrderProduct) { _ptotalPrice += Convert.ToDouble(group.price) * Convert.ToDouble(group.quantity); string img = ""; foreach (var food in group.Addon) { if (food.AddonMedia == null) { img = "product_Placeholder.png"; } else { img = string.IsNullOrEmpty(food.AddonMedia.media) ? "product_Placeholder.png" : CommonLib.img_MainUrl + food.AddonMedia.media; } } CartViewModel newGroup = new CartViewModel(group.name, group.quantity, group.price, Convert.ToString(group.id), group.product_id, "", img, ""); foreach (var food in group.Addon) { _ptotalPrice += Convert.ToDouble(food.price) * Convert.ToDouble(food.quantity); newGroup.Add(new CartProduct { Note = (!string.IsNullOrEmpty(food.note)) ? AppResources.noteDetails + ":- " + food.note : "", Name = food.name, AddonCategory = "", AddonId = food.addon_id, AddonPrice = food.price, AddonQty = food.quantity, PSQLId = "", ProductId = food.product_id }); } _expandedGroups.Add(newGroup); } GroupedView.ItemsSource = _expandedGroups; if (_expandedGroups.Count == 0) { emptyCartLbl.IsVisible = true; totalLyt.IsVisible = false; } else { emptyCartLbl.IsVisible = false; totalLyt.IsVisible = true; totalPrice.Text = "Riyal " + _ptotalPrice; } Loader.CloseAllPopup(); } else { Loader.CloseAllPopup(); if (App.Lng == "ar-AE") { await App.Current.MainPage.Navigation.PushPopupAsync(new ShowMessage(result.msg_ar)); } else { await App.Current.MainPage.Navigation.PushPopupAsync(new ShowMessage(result.msg_en)); } await Task.Delay(1000); ShowMessage.CloseAllPopup(); } } catch (Exception ex) { Loader.CloseAllPopup(); } }