Ejemplo n.º 1
0
        private async void CreateClub_Click(object sender, EventArgs e)
        {
            bool     hasError = false;
            EditText clubName = FindViewById <EditText>(Resource.Id.et_createClub_clubName);

            if (string.IsNullOrWhiteSpace(clubName.Text))
            {
                clubName.Error = "Въведете име";
                hasError       = true;
            }

            if (_imageStream == null)
            {
                Toast.MakeText(this, Literals.SelectPicture, ToastLength.Long).Show();
                hasError = true;
            }

            if (!hasError)
            {
                string email = Intent.GetStringExtra("email");
                HttpResponseMessage response = await RestManager.CreateClub(new CreateClub
                {
                    Email     = email,
                    Name      = clubName.Text,
                    ClubPhoto = _imageStream
                });

                if (response.IsSuccessStatusCode)
                {
                    Intent intent = new Intent(this, typeof(UserProfileActivity));
                    StartActivity(intent);
                }
                else
                {
                    string message = await response.Content.ReadAsStringAsync();

                    Toast.MakeText(this, message, ToastLength.Long).Show();
                }
            }
        }