Exemple #1
0
        public ReservationCreateViewModel(Page page, ReservationModel reservation) : base(page)
        {
            _reservation            = reservation;
            ReservationButtonStatus = true;

            string[] nameParts = SessionService.Account.UserName.Split(' ');
            if (nameParts.Length > 1)
            {
                UserName = string.Concat(nameParts[0], " ", nameParts[1]);
            }
            else
            {
                UserName = nameParts[0];
            }

            DoReservationCommand = new Command(async() =>
            {
                ReservationButtonStatus = false;
                IsBusy = true;

                try
                {
                    ReservationStatus response;
                    if (Reservation.Pitch.PitchType == PitchType.Single)
                    {
                        response = await RestService.Instance.DoReservationSingleAsync(reservation);
                    }
                    else
                    {
                        response = await RestService.Instance.DoReservationMultipleAsync(reservation);
                    }

                    MessagesTexts message = MessagesTexts.error_message;
                    if (response == ReservationStatus.Pending)
                    {
                        message = MessagesTexts.reservation_pending;
                    }
                    else if (response == ReservationStatus.Conflict)
                    {
                        message = MessagesTexts.reservation_conflict;
                    }
                    else if (response == ReservationStatus.Ok)
                    {
                        message = MessagesTexts.reservation_ok;
                    }

                    await DisplayAlertAsync(message);

                    if (response == ReservationStatus.Ok || response == ReservationStatus.Pending)
                    {
                        App.NavigateToHomeAsync(true);
                    }
                }
                catch { await DisplayAlertAsync(MessagesTexts.error_message); }

                IsBusy = false;
            });
        }
Exemple #2
0
 public async Task DisplayAlertAsync(MessagesTexts messageKey)
 {
     await _page.DisplayAlert(T.GetValue("app_name"), T.GetValue(messageKey.ToString()), T.GetValue("ok"));
 }
Exemple #3
0
 public async Task DisplayAlertAsync(MessagesTexts messageKey)
 {
     await DisplayAlertAsync(T.GetValue(messageKey.ToString()));
 }