Exemplo n.º 1
0
        private async void EditButton_Click(object sender, EventArgs e)
        {
            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 startTime = new DateTime(
                _startTimeDay.Year,
                _startTimeDay.Month + 1, // January-0 December-11
                _startTimeDay.DayOfMonth,
                _startTimeHour.Hour,
                _startTimeHour.Minute,
                0);

            ClubEventCreateRequest clubEventCreateRequest = new ClubEventCreateRequest
            {
                EventId     = _clubEvent.Id,
                Title       = _title.Text,
                Description = _description.Text,
                StartTime   = startTime,
                EventType   = (EventType)_eventTypesSpinner.SelectedItemPosition,
                Coordinates = _markerPosition
            };

            AndHUD.Shared.Show(this, "Промяна на събитие…");
            var response = await RestManager.EditClubEvent(clubEventCreateRequest);

            AndHUD.Shared.Dismiss(this);
            if (response.IsSuccessStatusCode)
            {
                Toast.MakeText(this, "Успешна промяна на събитие!", ToastLength.Short).Show();
            }
            else
            {
                Toast.MakeText(this, "Неуспешна промяна на събитие!", ToastLength.Short).Show();
            }
        }