Example #1
0
        private async void CreateButton_Click(object sender, System.EventArgs e)
        {
            var  title       = FindViewById <EditText>(Resource.Id.et_createClubEvent_clubEventTitle);
            var  description = FindViewById <EditText>(Resource.Id.et_createClubEvent_clubEventDescription);
            bool isValid     = true;

            if (string.IsNullOrWhiteSpace(title.Text))
            {
                title.Error = Literals.PleaseEnterTitle;
                isValid     = false;
            }
            if (string.IsNullOrWhiteSpace(description.Text))
            {
                description.Error = Literals.PleaseEnterDescription;
                isValid           = false;
            }

            if (_markerPosition == null)
            {
                Toast.MakeText(this, Literals.PleaseEnterLocation, ToastLength.Long).Show();
                isValid = false;
            }

            if (!isValid)
            {
                return;
            }

            var clubId    = Intent.GetIntExtra("clubId", 0);
            var startTime = new DateTime(
                _startTimeDay.Year,
                _startTimeDay.Month + 1, // January-0 December-11
                _startTimeDay.DayOfMonth,
                _startTimeHour.Hour,
                _startTimeHour.Minute,
                0);

            ClubEventCreateRequest clubEventCreateRequest = new ClubEventCreateRequest
            {
                ClubId      = clubId,
                Title       = title.Text,
                Description = description.Text,
                StartTime   = startTime,
                EventType   = (EventType)_eventTypesSpinner.SelectedItemPosition,
                Coordinates = _markerPosition
            };

            AndHUD.Shared.Show(this, "Създаване на събитие…");
            var response = await RestManager.CreateClubEvent(clubEventCreateRequest);

            AndHUD.Shared.Dismiss(this);
            if (response.IsSuccessStatusCode)
            {
                Toast.MakeText(this, "Успешно създадено събитие!", ToastLength.Short).Show();
                //var intent = new Intent(this, typeof(ClubEventsFragment));
                //StartActivity(intent);
            }
            else
            {
                Toast.MakeText(this, "Неуспешно създадено събитие!", ToastLength.Short).Show();
            }
        }