Beispiel #1
0
        /// <summary>
        /// This method is in charge of retrieving the result of the Rate Recipe dialog fragment.
        /// </summary>
        /// <param name="sender"> Reference to the object that raised the event </param>
        /// <param name="e"> Contains the event data </param>
        private void RateResult(object sender, SendRateEvent e)
        {
            string toastText;

            switch (e.Message)
            {
            case "-1":
                toastText = "Please choose a rating";
                break;

            case "1":
                toastText = "You cannot rate this recipe. You either are its owner or you already rated it.";
                break;

            default:
            {
                toastText = "Recipe rated! Redirecting to the newsfeed...";

                using var webClient = new WebClient { BaseAddress = "http://" + MainActivity.Ipv4 + ":8080/CookTime_war/cookAPI/" };
                var url = "resources/getUser?id=" + _loggedId;

                webClient.Headers[HttpRequestHeader.ContentType] = "application/json";
                var userJson = webClient.DownloadString(url);

                var intent = new Intent(this, typeof(NewsfeedActivity));
                intent.PutExtra("User", userJson);
                intent.SetFlags(ActivityFlags.NewTask | ActivityFlags.ClearTask);
                StartActivity(intent);
                OverridePendingTransition(Android.Resource.Animation.SlideInLeft, Android.Resource.Animation.SlideOutRight);
                break;
            }
            }
            _toast = Toast.MakeText(this, toastText, ToastLength.Long);
            _toast.Show();
        }
        /// <summary>
        /// This method is in charge of retrieving the result of the Rate Chef dialog fragment.
        /// </summary>
        /// <param name="sender"> Reference to the object that raised the event </param>
        /// <param name="e"> Contains the event data </param>
        private void RateResult(object sender, SendRateEvent e)
        {
            Toast  toast;
            string toastText;

            switch (e.Message)
            {
            case "-1":
                toastText = "Please choose a rating";
                break;

            case "1":
                toastText = "You already rated this chef.";
                break;

            default:
            {
                toastText = "Chef rated! Refreshing the profile...";

                using var webClient = new WebClient { BaseAddress = "http://" + MainActivity.Ipv4 + ":8080/CookTime_war/cookAPI/" };
                var url = "resources/getUser?id=" + _user.email;

                webClient.Headers[HttpRequestHeader.ContentType] = "application/json";
                var userJson = webClient.DownloadString(url);

                var intent = new Intent(this, typeof(PrivProfileActivity));
                intent.PutExtra("User", userJson);
                intent.PutExtra("LoggedId", _loggedId);
                StartActivity(intent);
                OverridePendingTransition(Android.Resource.Animation.SlideInLeft, Android.Resource.Animation.SlideOutRight);
                Finish();
                break;
            }
            }
            toast = Toast.MakeText(this, toastText, ToastLength.Long);
            toast.Show();
        }