public async void GetDeals(int len, int amount, bool addon)
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true; noItems = false;

            try
            {
                ObservableCollection <Product> result = null;
                if (CrossConnectivity.Current.IsConnected)
                {
                    result = await ProductService.Instance.FetchDeals(amount, null, null, len);

                    if (result == null)
                    {
                        isDone = true;
                        if (DealList.Count < 1)
                        {
                            noItems = true;
                        }
                        return;
                    }
                    OfflineService.Write <ObservableCollection <Product> >(result, Strings.DealList_Offline_fileName, null);
                }
                else
                {
                    result = await OfflineService.Read <ObservableCollection <Product> >(Strings.DealList_Offline_fileName, null);
                }

                if (result == null)
                {
                    isDone = true;
                    if (DealList.Count < 1)
                    {
                        noItems = true;
                    }
                    return;
                }
                ProductList = result;
                if (addon)
                {
                    DealList.AddRange(formData(result));
                }
                else
                {
                    DealList = formData(result);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(Keys.TAG + ex);
                DialogService.ShowError(Strings.SomethingWrong);
                Crashes.TrackError(ex);
            }
            finally { IsBusy = false; }
        }
Esempio n. 2
0
        public async void GetCart()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true; noItems = false;

            try
            {
                CartType result = null;
                if (CrossConnectivity.Current.IsConnected)
                {
                    result = await CartService.Instance.FetchUserCart(AccountService.Instance.Current_Account.Email);

                    if (result == null)
                    {
                        noItems    = true; hidecheck = false;
                        MyCartList = new ObservableCollection <mCart>();
                        CalculateGrandPrice();
                        return;
                    }
                    OfflineService.Write <CartType>(result, Strings.MyCart_Offline_fileName, null);
                }
                else
                {
                    result = await OfflineService.Read <CartType>(Strings.MyCart_Offline_fileName, null);
                }

                if (result == null)
                {
                    noItems    = true; hidecheck = false;
                    MyCartList = new ObservableCollection <mCart>();
                    CalculateGrandPrice();
                    return;
                }

                CartType orgnize = result;

                MyProductList = orgnize.Prop1;

                MyCartList = await BindClickables(FormatCart(MyProductList, orgnize.Prop2));

                CalculateGrandPrice();
                hidecheck = true;
            }
            catch (Exception ex)
            {
                Debug.WriteLine(Keys.TAG + ex);
                DialogService.ShowError(Strings.SomethingWrong);
                Crashes.TrackError(ex);
            }
            finally { IsBusy = false; IsListRefereshing = false; }
        }
        public async Task <ObservableCollection <Product> > GetDeals()
        {
            if (IsBusy_Deal)
            {
                return(null);
            }

            IsBusy_Deal = true;

            try
            {
                ObservableCollection <Product> result = null;

                if (CrossConnectivity.Current.IsConnected)
                {
                    result = await ProductService.Instance.FetchDeals(6, null, null, 0);

                    if (result == null)
                    {
                        //No Item Found(WORK ON)

                        return(new ObservableCollection <Product>());
                    }
                    OfflineService.Write <ObservableCollection <Product> >(result, Strings.DashDeals_Offline_fileName, null);
                }
                else
                {
                    result = await OfflineService.Read <ObservableCollection <Product> >(Strings.DashDeals_Offline_fileName, null);
                }

                if (result == null)
                {
                    //No Item Found(WORK ON)

                    return(new ObservableCollection <Product>());
                }

                for (var i = 0; i < result.Count; i++)
                {
                    result[i].Thumbnail = result[i].Images[0];
                }

                return(result);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(Keys.TAG + ex);
                DialogService.ShowError(Strings.SomethingWrong);
                Crashes.TrackError(ex);
                return(null);
            }
            finally { IsBusy_Deal = false; }
        }
        private async void GetMyNotfiy(string email)
        {
            if (IsBusy)
            {
                return;
            }


            try
            {
                IsBusy  = true;
                IsEmpty = false;

                if (CrossConnectivity.Current.IsConnected)
                {
                    var result = await NotifyService.Instance.FetchNotfiy(email);

                    if (result == null)
                    {
                        IsEmpty    = true;
                        NotifyList = new ObservableCollection <mNotify>();
                        return;
                    }

                    NotifyList = formatData(result);

                    OfflineService.Write <ObservableCollection <mNotify> >(result, Strings.Notify_Offline_fileName, null);
                }
                else
                {
                    var result = await OfflineService.Read <ObservableCollection <mNotify> >(Strings.Notify_Offline_fileName, null);

                    if (result == null)
                    {
                        IsEmpty    = true;
                        NotifyList = new ObservableCollection <mNotify>();
                        return;
                    }

                    NotifyList = formatData(result);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(Keys.TAG + ex);
                DialogService.ShowError(Strings.SomethingWrong);
                Crashes.TrackError(ex);
            }
            finally { IsBusy = false; IsRefresing = false; }
        }
Esempio n. 5
0
        public async void GetSave()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true; noItems = false;

            try
            {
                ObservableCollection <Product> result = null;
                if (CrossConnectivity.Current.IsConnected)
                {
                    result = await SavelaterService.Instance.Fetchitems(AccountService.Instance.Current_Account.Email);

                    if (result == null)
                    {
                        noItems    = true;
                        MySaveList = new ObservableCollection <mSavelaterR>();
                        return;
                    }
                    OfflineService.Write <ObservableCollection <Product> >(result, Strings.MySaveLater_Offline_fileName, null);
                }
                else
                {
                    result = await OfflineService.Read <ObservableCollection <Product> >(Strings.MySaveLater_Offline_fileName, null);
                }



                if (result == null)
                {
                    noItems    = true;
                    MySaveList = new ObservableCollection <mSavelaterR>();
                    return;
                }
                MyProductList = result;
                MySaveList    = await BindClickables(FormatList(result));
            }
            catch (Exception ex)
            {
                Debug.WriteLine(Keys.TAG + ex);
                DialogService.ShowError(Strings.SomethingWrong);
                Crashes.TrackError(ex);
            }
            finally { IsBusy = false; IsListRefereshing = false; }
        }
Esempio n. 6
0
        public async void GetAddresses()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true; noItems = false;

            try
            {
                ObservableCollection <mOrderAddress> result = null;
                if (CrossConnectivity.Current.IsConnected)
                {
                    result = await AddressService.Instance.FetchAddresses(AccountService.Instance.Current_Account.Email, 100, 0);

                    if (result == null)
                    {
                        noItems   = true;
                        Addresses = new ObservableCollection <mOrderAddress>();
                        return;
                    }
                    OfflineService.Write <ObservableCollection <mOrderAddress> >(result, Strings.MyAddress_Offline_fileName, null);
                }
                else
                {
                    result = await OfflineService.Read <ObservableCollection <mOrderAddress> >(Strings.MyAddress_Offline_fileName, null);
                }



                if (result == null)
                {
                    noItems   = true;
                    Addresses = new ObservableCollection <mOrderAddress>();
                    return;
                }
                Addresses = await BindClickables(result);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(Keys.TAG + ex);
                DialogService.ShowError(Strings.SomethingWrong);
                Crashes.TrackError(ex);
            }
            finally { IsBusy = false; }
        }
        public async void GetMyOrders()
        {
            try
            {
                noItems = false;
                if (CrossConnectivity.Current.IsConnected)
                {
                    var result = await OrderService.Instance.FetchOrders(AccountService.Instance.Current_Account.Email);


                    if (result == null)
                    {
                        noItems  = true;
                        MyOrders = new ObservableCollection <mOrder>();
                        return;
                    }

                    MyOrders = FormatData(result);

                    OfflineService.Write <ObservableCollection <mOrder> >(result, Strings.Order_Offline_fileName, null);
                }
                else
                {
                    var result = await OfflineService.Read <ObservableCollection <mOrder> >(Strings.Order_Offline_fileName, null);

                    if (result == null)
                    {
                        noItems  = true;
                        MyOrders = new ObservableCollection <mOrder>();
                        return;
                    }

                    MyOrders = FormatData(result);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(Keys.TAG + ex);
                DialogService.ShowError(Strings.SomethingWrong);
                Crashes.TrackError(ex);
            }
            finally { IsListRefereshing = false; IsBusy = false; }
        }
        public async Task <ObservableCollection <mUserItem> > GetRandomProducts(int amount, int len)
        {
            IsBusy = true;

            try
            {
                //ObservableCollection<mUserItem> result = null;

                if (CrossConnectivity.Current.IsConnected)
                {
                    result = await ItemService.Instance.FetchRandom(amount, null, null, len);

                    if (result == null)
                    {
                        DialogService.ShowToast("No More Results");

                        return(new ObservableCollection <mUserItem>());
                    }
                    OfflineService.Write <ObservableCollection <mUserItem> >(result, Strings.BuySellDash_Offline_fileName, null);
                }
                else
                {
                    result = await OfflineService.Read <ObservableCollection <mUserItem> >(Strings.BuySellDash_Offline_fileName, null);

                    if (result == null)
                    {
                        IsNoConnection = true;
                    }
                }

                if (result == null)
                {
                    //No Item Found(WORK ON)

                    return(new ObservableCollection <mUserItem>());
                }

                if (result.Count > 19)
                {
                    ShowLoadMore = true;
                }

                for (var i = 0; i < result.Count; i++)
                {
                    result[i].Thumbnail = result[i].Images[0];

                    if (i == result.Count)
                    {
                        result[i].ThumbnailHeight = "1000";

                        continue;
                    }

                    result[i].ThumbnailHeight = "100";


                    int max_Name_Length = 28;

                    if (result[i].Name.Length > max_Name_Length)
                    {
                        result[i].SummaryName = result[i].Name.Substring(0, max_Name_Length) + "...";
                    }
                    else
                    {
                        result[i].SummaryName = result[i].Name;
                    }
                }

                IsNoConnection = false; return(result);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(Keys.TAG + ex);
                DialogService.ShowError(Strings.SomethingWrong);
                Crashes.TrackError(ex);
                return(null);
            }
            finally { IsBusy = false; }
        }
Esempio n. 9
0
        public async void GetMyItems(int amount, int len, bool addon = false)
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;
            try
            {
                noItems = false;

                ObservableCollection <mUserItem> result = null;
                if (CrossConnectivity.Current.IsConnected)
                {
                    result = await ItemService.Instance.FetchUsersItems(AccountService.Instance.Current_Account.Email, amount, len);

                    if (result != null)
                    {
                        var newResult = await BindDelete(result);

                        for (var i = 0; i < newResult.Count; i++)
                        {
                            newResult[i].Thumbnail = newResult[i].Images[0];
                            //newResult[i].CreatedDate = newResult[i].CreatedDate.Split('T')[0];

                            int max_description_length = 159;
                            int max_Name_length        = 21;

                            if (newResult[i].Name.Length > max_Name_length)
                            {
                                newResult[i].SummaryName = newResult[i].Name.Substring(0, max_Name_length) + "...";
                            }
                            else
                            {
                                newResult[i].SummaryName = newResult[i].Name;
                            }

                            if (newResult[i].Description.Length > max_description_length)
                            {
                                newResult[i].SummaryDesc = newResult[i].Description.Substring(0, max_description_length) + "...";
                            }
                            else
                            {
                                newResult[i].SummaryDesc = newResult[i].Description;
                            }

                            if (newResult[i].Visable == "false")
                            {
                                newResult[i].Visable = "Not Visible";
                            }
                            else
                            {
                                newResult[i].Visable = "Visible";
                            }
                        }
                        if (addon)
                        {
                            MyItemList.AddRange(newResult);
                        }
                        else
                        {
                            MyItemList = newResult;
                        }
                        return;
                    }
                    OfflineService.Write <ObservableCollection <mUserItem> >(result, Strings.MyItems_Offline_fileName, null);
                }
                else
                {
                    result = await OfflineService.Read <ObservableCollection <mUserItem> >(Strings.MyItems_Offline_fileName, null);
                }


                if (result != null)
                {
                    var newResult = await BindDelete(result);

                    for (var i = 0; i < newResult.Count; i++)
                    {
                        newResult[i].Thumbnail   = newResult[i].Images[0];
                        newResult[i].CreatedDate = newResult[i].CreatedDate.Split('T')[0];
                    }
                    if (addon)
                    {
                        MyItemList.AddRange(newResult);
                    }
                    else
                    {
                        MyItemList = newResult;
                    }
                    return;
                }

                if (addon)
                {
                    isDone = true;
                }
                else
                {
                    noItems    = true;
                    MyItemList = new ObservableCollection <mUserItem>();
                }
            }
            catch (Exception ex)
            {
                DialogService.ShowError(Strings.SomethingWrong);
                Debug.WriteLine(Keys.TAG + ex);
                Crashes.TrackError(ex);
            }
            finally { IsListRefereshing = false; IsBusy = false; }
        }
        public async Task <ObservableCollection <Product> > GetInterestProductsAsync()
        {
            IsBusy = true;

            try
            {
                ObservableCollection <Product> result = null;

                if (CrossConnectivity.Current.IsConnected)
                {
                    result = await ProductService.Instance.FetchUserInterets(AccountService.Instance.Current_Account.Email);

                    if (result == null)
                    {
                        //ComeBack
                        return(new ObservableCollection <Product>());
                    }
                    OfflineService.Write <ObservableCollection <Product> >(result, Strings.MyInterest_Offline_fileName, null);
                }
                else
                {
                    result = await OfflineService.Read <ObservableCollection <Product> >(Strings.MyInterest_Offline_fileName, null);

                    if (result == null)
                    {
                        IsNoConnection = true;
                    }
                }


                if (result == null)
                {
                    //ComeBack
                    return(new ObservableCollection <Product>());
                }

                for (var i = 0; i < result.Count; i++)
                {
                    result[i].Thumbnail = result[i].Images[0];

                    if (i == result.Count)
                    {
                        result[i].ThumbnailHeight = "1000";

                        continue;
                    }

                    result[i].ThumbnailHeight = "100";

                    int max_Name_Length = 39;

                    if (result[i].Name.Length > max_Name_Length)
                    {
                        result[i].SummaryName = result[i].Name.Substring(0, max_Name_Length) + "...";
                    }
                    else
                    {
                        result[i].SummaryName = result[i].Name;
                    }
                }

                IsNoConnection = false; return(result);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(Keys.TAG + ex);
                DialogService.ShowError(Strings.SomethingWrong);
                Crashes.TrackError(ex);
                return(null);
            }
            finally { IsBusy = false; }
        }
        public async Task <ObservableCollection <Product> > GetRecentroducts()
        {
            if (IsBusy_Recent)
            {
                return(null);
            }
            IsBusy_Recent = true;

            try
            {
                ObservableCollection <Product> result = null;

                if (CrossConnectivity.Current.IsConnected)
                {
                    result = await ProductService.Instance.FetchRecent(8, null, null, 0);

                    if (result == null)
                    {
                        //No Item Found(WORK ON)

                        return(new ObservableCollection <Product>());
                    }
                    OfflineService.Write <ObservableCollection <Product> >(result, Strings.DashRecent_Offline_fileName, null);
                }
                else
                {
                    result = await OfflineService.Read <ObservableCollection <Product> >(Strings.DashRecent_Offline_fileName, null);

                    if (result == null)
                    {
                        IsNoConnection = true;
                    }
                }


                if (result == null)
                {
                    //No Item Found(WORK ON)

                    return(new ObservableCollection <Product>());
                }

                for (var i = 0; i < result.Count; i++)
                {
                    result[i].Thumbnail = result[i].Images[0];

                    int max_Name_length = 24;

                    if (result[i].Name.Length > max_Name_length)
                    {
                        result[i].SummaryName = result[i].Name.Substring(0, max_Name_length) + "...";
                    }
                    else
                    {
                        result[i].SummaryName = result[i].Name;
                    }
                }

                IsNoConnection = false; return(result);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(Keys.TAG + ex);
                DialogService.ShowError(Strings.SomethingWrong);
                Crashes.TrackError(ex);
                return(null);
            }
            finally { IsBusy_Recent = false; }
        }
        public async void GetQuestionList(int len, int amount, bool addon = false, string txt = null)
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true; IsEmpty = false;
            try
            {
                string link = Keys.Url_Main + "item-question/get-question/" + Itemid;
                if (txt != null)
                {
                    link += "?Search=" + txt;
                }


                ObservableCollection <mQuestion> result = new ObservableCollection <mQuestion>();
                if (CrossConnectivity.Current.IsConnected)
                {
                    result = await QuestionService.Instance.FetchQuestions(link, len, amount);

                    if (result == null)
                    {
                        if (addon)
                        {
                            isDone = true;
                            return;
                        }
                        IsEmpty = true;
                        return;
                    }
                    OfflineService.Write <ObservableCollection <mQuestion> >(result, Strings.ItemQuestion_Offline_fileName, null);
                }
                else
                {
                    result = await OfflineService.Read <ObservableCollection <mQuestion> >(Strings.ItemQuestion_Offline_fileName, null);
                }


                if (result == null)
                {
                    if (addon)
                    {
                        isDone = true;
                        return;
                    }
                    IsEmpty = true;
                    return;
                }

                if (addon)
                {
                    Questionlist.AddRange(result);
                }
                else
                {
                    Questionlist = result;
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(Keys.TAG + ex);
                DialogService.ShowError(Strings.SomethingWrong);
                Crashes.TrackError(ex);
                return;
            }
            finally { IsBusy = false; IsListRefereshing = false; }
        }