Exemplo n.º 1
0
        public async Task <string> RateProduct(mRate rate)
        {
            try
            {
                var Itemcreds = Newtonsoft.Json.JsonConvert.SerializeObject(rate);

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

                using (var client = new HttpClient())
                {
                    HttpResponseMessage response = await client.PutAsync(Keys.Url_Main + "product/rate/post", 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");
                        }

                        DialogService.ShowError(Strings.ServerFailed);
                        return(callback.Mess);
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(Keys.TAG + ex);
                return(Strings.ServerFailed);
            }
        }
Exemplo n.º 2
0
        public async void RateItem(int RateNum, string itemId)
        {
            if (IsBusy)
            {
                return;
            }

            try
            {
                DialogService.ShowLoading("Please wait");
                mRate rate = new mRate()
                {
                    Rate   = RateNum.ToString(),
                    By     = AccountService.Instance.Current_Account.Email,
                    Itemid = itemId.ToString()
                };

                var result = await ProductService.Instance.RateProduct(rate);

                DialogService.HideLoading();

                if (result == "true")
                {
                    Finsih.Add(itemId);
                    DialogService.ShowToast("Thank you for your feedback");
                    return;
                }

                DialogService.ShowError(result);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(Keys.TAG + ex);
                DialogService.ShowError(Strings.SomethingWrong);
                Crashes.TrackError(ex);
            }
            finally { IsBusy = false; }
        }