示例#1
0
 public OrderDetail(mOrder order)
 {
     _order    = order;
     viewModel = new Order_OrderDetails_ViewModel(order, new PageService(Navigation));
     InitializeComponent();
     PopulateItemList(order.Items);
 }
示例#2
0
        private async void FetchItems(mOrder order)
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;


            try
            {
                DialogService.ShowLoading("Fetching Items");

                ObservableCollection <Product> products = new ObservableCollection <Product>();

                for (var i = 0; i < order.Items.Count; i++)
                {
                    Product item = await ProductService.Instance.FetchProduct(order.Items[i].ItemId);

                    item.Thumbnail = item.Images[0];
                    products.Add(item);
                }


                RateList = products;
                DialogService.HideLoading();
            }catch (Exception ex)
            {
                Debug.WriteLine(Keys.TAG + ex);
                DialogService.ShowError(Strings.SomethingWrong);
                Crashes.TrackError(ex);
            }
            finally { IsBusy = false; }
        }
示例#3
0
        public async Task <string> UpdateDetail(mOrder order)
        {
            try
            {
                var Itemcreds = Newtonsoft.Json.JsonConvert.SerializeObject(order);

                HttpContent ItemContent = new StringContent(Itemcreds, Encoding.UTF8, "application/json");

                using (var client = new HttpClient())
                {
                    HttpResponseMessage response = await client.PutAsync(Keys.Url_Main + "order/update-detail", ItemContent);

                    using (HttpContent spawn = response.Content)
                    {
                        string content = await spawn.ReadAsStringAsync();

                        mServerCallback callback = Newtonsoft.Json.JsonConvert.DeserializeObject <mServerCallback>(content);

                        if (callback.Status == "true")
                        {
                            return("true");
                        }

                        return(callback.Mess);
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(Keys.TAG + ex);
                return(Strings.HttpFailed);
            }
        }
示例#4
0
 public RateList(mOrder order)
 {
     viewModel = new Rate_RateList_ViewModel(order);
     InitializeComponent();
     InitTaps();
     listView.ItemSelected += ListView_ItemSelected;
     listView.SelectedItem  = ((ObservableCollection <Product>)listView.ItemsSource).FirstOrDefault();
 }
示例#5
0
        private async void UpdateAction()
        {
            if (BgUpdateBtn == "Gray")
            {
                return;
            }

            if (_order.Status == Keys.OrderStatus[3] || _order.Status == Keys.OrderStatus[4] || _order.Status == Keys.OrderStatus[5])
            {
                var ans = await DialogService.DisplayAlert("Ok", null, "Notice", "Order can not be updated at this stage");

                return;
            }

            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                DialogService.ShowLoading("Updating Order");

                mOrder updateOrder = new mOrder()
                {
                    OrderId      = _order.OrderId,
                    OwnerEmail   = AccountService.Instance.Current_Account.Email,
                    DeliveryTime = DeliveryTime,
                    Address1     = Address1,
                    Address2     = Address2,
                    PhoneNumber  = PhoneNumber,
                    Name         = Name
                };

                var result = await OrderService.Instance.UpdateDetail(updateOrder);

                DialogService.HideLoading();

                if (result != "true")
                {
                    DialogService.ShowError(result);
                    return;
                }
                CrossSettings.Current.AddOrUpdateValue <bool>("StatusUpdate", true);
                DialogService.ShowSuccess("Order Updated");
            }
            catch (Exception ex)
            {
                Crashes.TrackError(ex);
            }
            finally { IsBusy = true; isUpdatable = false; }
        }
示例#6
0
 public Order_OrderDetails_ViewModel(mOrder order, IPageService pageService)
 {
     UpdateCommand = new Command(() => UpdateAction());
     _order        = order;
     _pageService  = pageService;
     OrderId       = order.OrderId; OrderStatus = order.Status; OrderDate = order.Order_At.Split('T')[0]; OrderTotal = order.GrandPrice;
     Address1      = order.Address1; Address2 = order.Address2; Name = order.Name; DeliveryTime = order.DeliveryTime; PhoneNumber = order.PhoneNumber;
     ItemTotal     = order.ItemTotal; TaxTotal = order.TaxPrice; ShippingTotal = order.ShippingPrice; GrandTotal = order.GrandPrice; OrderNumber = order.OrderNumber;
     if (order.OrderMessage != null)
     {
         OrderMessage = order.OrderMessage;
         hasMessage   = true;
     }
     Check_Status_Stage();
 }
示例#7
0
        public async Task <mOrder> FetchOrder(string orderId)
        {
            try
            {
                var httpClient = new HttpClient();

                var response = await httpClient.GetAsync(Keys.Url_Main + "order/get-one/" + orderId);

                response.EnsureSuccessStatusCode();

                string content = await response.Content.ReadAsStringAsync();

                mServerCallback callback = Newtonsoft.Json.JsonConvert.DeserializeObject <mServerCallback>(content);

                if (callback.Status == "true")
                {
                    mOrder newitem = new mOrder();

                    newitem = Newtonsoft.Json.JsonConvert.DeserializeObject <mOrder>(callback.Data.ToString());


                    if (newitem == null)
                    {
                        return(null);
                    }

                    return(newitem);
                }
                else
                {
                    DialogService.ShowError(Strings.ServerFailed);
                    return(null);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(Keys.TAG + ex);
                DialogService.ShowErrorToast(Strings.HttpFailed);
                return(null);
            }
        }
        private async void PlaceOrder(ObservableCollection <mCart> cartList)
        {
            if (String.IsNullOrEmpty(Address1))
            {
                DialogService.ShowErrorToast("Please Add Address");
                return;
            }

            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                DialogService.ShowLoading("Processing Order");

                ObservableCollection <mOrderItems> orderItems = new ObservableCollection <mOrderItems>();

                for (var i = 0; i < cartList.Count; i++)
                {
                    orderItems.Add(new mOrderItems {
                        ItemId = cartList[i].ProductId, ItemNameSub = cartList[i].Name, ItemName = cartList[i].bName, Quantity = cartList[i].Quantity, Price = cartList[i].Price, Thumbnail = cartList[i].Thumbnail, Seller = cartList[i].Manufacturer
                    });
                }
                mOrder newOrder = new mOrder()
                {
                    GrandPrice    = GrandTotal,
                    ItemTotal     = ItemTotal,
                    ShippingPrice = ShippingTotal,
                    TaxPrice      = TaxTotal,
                    OwnerEmail    = AccountService.Instance.Current_Account.Email,
                    DeliveryTime  = DeliveryTime,
                    Items         = orderItems,
                    Address1      = Address1,
                    Address2      = Address2,
                    PhoneNumber   = _address.PhoneNumber,
                    ProfileNumber = AccountService.Instance.Current_Account.PhoneNumber,
                    CardInfo      = CurrentCard,
                    Name          = Name
                };

                if (UseCard)
                {
                    newOrder.PaymentType = "Card";
                }
                else
                {
                    newOrder.PaymentType = "NoCard";
                }

                var result = await OrderService.Instance.SendOrder(newOrder);

                DialogService.HideLoading();

                if (result != "true")
                {
                    DialogService.ShowError(result);
                    return;
                }

                CartService.Instance.ClearCart(AccountService.Instance.Current_Account.Email);

                DialogService.ShowSuccess("Thank You, Your Order Have Been Sent");
                CrossSettings.Current.AddOrUpdateValue <bool>("OrderDone", true);

                _pageSerivce.ShowMain(new RootPage(false, null, new OrderList()));
            }
            catch (Exception ex)
            {
                Debug.WriteLine(Keys.TAG + ex);
                DialogService.ShowError(Strings.SomethingWrong);
                Crashes.TrackError(ex);
            }
            finally { IsBusy = false; }
        }
示例#9
0
 public Rate_RateList_ViewModel(mOrder order)
 {
     RateCommand = new Command(() => RateAction());
     FetchItems(order);
 }
示例#10
0
        private async void ListView_ItemSelected(object sender, SelectedItemChangedEventArgs e)
        {
            var item = e.SelectedItem as mNotify;

            if (item != null)
            {
                if (item.Why == Keys.NotifyWhys[9])//rate
                {
                    DialogService.ShowLoading("Please wait");
                    mOrder order = await OrderService.Instance.FetchOrder(item.Objecter);

                    DialogService.HideLoading();

                    if (order == null)
                    {
                        return;
                    }

                    await Navigation.PushAsync(new RateList(order));
                }
                else if (item.Type == Keys.NotifyTypes[2]) //order
                {
                    DialogService.ShowLoading("Please wait");
                    mOrder order = await OrderService.Instance.FetchOrder(item.Objecter);

                    DialogService.HideLoading();

                    if (order == null)
                    {
                        return;
                    }

                    await Navigation.PushAsync(new OrderDetail(order));
                }
                else if (item.Why == Keys.NotifyWhys[2])//answer-question
                {
                    mQuestion question2 = await QuestionService.Instance.FetchQuestion(item.Objecter);

                    var response = await DialogService.DisplayAlert("View item", "Dismiss", "Q:" + question2.Question, "A:" + question2.Answer);

                    listView.SelectedItem = null;
                    if (!response)
                    {
                        return;
                    }

                    DialogService.ShowLoading("Relocating");
                    if (question2.IsItem == "True")
                    {
                        var Titem = await ItemService.Instance.FetchItem(question2.ProductId);

                        DialogService.HideLoading();

                        await Navigation.PushAsync(new ItemView(Titem));
                    }
                    else
                    {
                        var Tproduct = await ProductService.Instance.FetchProduct(question2.ProductId);

                        DialogService.HideLoading();

                        await Navigation.PushAsync(new ProductView(Tproduct));
                    }
                }
                else
                {
                    viewModel.NotifyAction(item);
                }
            }

            listView.SelectedItem = null;
        }