private async Task SaveAction(object itemName)
        {
            try
            {
                if (AccountService.Instance.Current_Account == null)
                {
                    AccountService.Instance.autho(null, "Dismiss");
                    return;
                }

                DialogService.ShowLoading("Saving Item");

                mSearchProduct listitem = (from itm in RecentList
                                           where itm.Name == itemName.ToString()
                                           select itm)
                                          .FirstOrDefault <mSearchProduct>();

                mSavelater item = new mSavelater()
                {
                    Owner     = AccountService.Instance.Current_Account.Email,
                    ProductId = listitem.Id
                };
                var result = await SavelaterService.Instance.Additem(item);

                DialogService.HideLoading();

                if (result == "true")
                {
                    DialogService.ShowToast("Item Saved");
                    return;
                }
                else
                {
                    DialogService.ShowError(result);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(Keys.TAG + ex);
                DialogService.ShowError(Strings.SomethingWrong);
                Crashes.TrackError(ex);
            }
        }
예제 #2
0
        public async Task <string> Additem(mSavelater item)
        {
            try
            {
                var Itemcreds = Newtonsoft.Json.JsonConvert.SerializeObject(item);

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

                using (var client = new HttpClient())
                {
                    System.Net.Http.HttpResponseMessage response = await client.PostAsync(Keys.Url_Main + "savelater/add", 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");
                        }
                        else if (callback.Mess == "Item Already Saved")
                        {
                            return("true");
                        }

                        return(callback.Mess);
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(Keys.TAG + ex);
                return(Strings.HttpFailed);
            }
        }