示例#1
0
        public string GetReservationStatus(ReservationStatus status)
        {
            switch (status)
            {
            case ReservationStatus.Ok:
                return(T.GetValue("reservation_ok_short"));

            case ReservationStatus.Pending:
                return(T.GetValue("reservation_pending_short"));

            case ReservationStatus.CancelPlace:
                return(T.GetValue("reservation_cancel_place_short"));

            case ReservationStatus.CancelUser:
                return(T.GetValue("reservation_cancel_user_short"));

            case ReservationStatus.Running:
                return(T.GetValue("reservation_running_short"));

            case ReservationStatus.Close:
                return(T.GetValue("reservation_close_short"));
            }

            return(T.GetValue("cancel"));
        }
示例#2
0
        async Task <bool> RegisterValidations()
        {
            if (!FunctionsService.ValidateEmail(Mail))
            {
                await _page.DisplayAlert(T.GetValue("app_name"), T.GetValue("mail_error"), T.GetValue("ok"));

                return(false);
            }

            return(true);
        }
示例#3
0
        async Task <bool> UserValidations()
        {
            if (!string.IsNullOrEmpty(User.Mail) && !FunctionsService.ValidateEmail(User.Mail))
            {
                await _page.DisplayAlert(T.GetValue("app_name"), T.GetValue("mail_error"), T.GetValue("ok"));

                return(false);
            }

            if (!FunctionsService.ValidatePhone(User.Phone))
            {
                await _page.DisplayAlert(T.GetValue("app_name"), T.GetValue("phone_error"), T.GetValue("ok"));

                return(false);
            }

            return(true);
        }
示例#4
0
        public async void GetPitchPrice()
        {
            IsBusy              = true;
            GettingValue        = T.GetValue("getting_price");
            GettingValueVisible = true;

            try
            {
                Value = await RestService.Instance.GetPitchPriceAsync(_reservation.Pitch.Id, _reservation.Date);

                GettingValueVisible = false;
            }
            catch
            {
                GettingValue = T.GetValue("getting_price_error");
            }

            IsBusy = false;
        }
示例#5
0
        void CreateHeadersAsync()
        {
            if (!_headerExist)
            {
                int    pitchCount  = 1;
                string pitchPrefix = string.Concat(T.GetValue("pitch_prefix_length"), " ");
                if (_binding.Pitches.Count > 3 && _binding.Pitches.Count <= 6)
                {
                    pitchPrefix = T.GetValue("pitch_prefix_short");
                }
                else if (_binding.Pitches.Count > 6)
                {
                    pitchPrefix = string.Empty;
                }

                foreach (PitchModel pitch in _binding.Pitches)
                {
                    #region Header

                    gridHeader.ColumnDefinitions.Add(new ColumnDefinition {
                        Width = new GridLength(1, GridUnitType.Star)
                    });
                    gridHeader.Children.Add(new Button {
                        Text = string.Concat(pitchPrefix, pitchCount), Style = (Style)Resources["titleButton"], Command = _binding.ShowPitchDescriptionCommand, CommandParameter = pitch.Description
                    }
                                            , pitchCount, 0);

                    #endregion

                    pitchCount++;
                }

                if (_place.FormatHour > 0)
                {
                    _fontSize = 8;
                }
                _headerExist = true; // Var for only create the header the first time
            }

            CreateDetailsAsync();
        }
示例#6
0
        public App()
        {
            try
            {
                InitializeComponent();

                if (Device.OS != TargetPlatform.Windows)
                {
                    DependencyService.Get <ILocalize>().SetLocale();
                }

                Page page = null;
                if (IsLogin)
                {
                    page = new HomeView();
                }
                else
                {
                    page = new LoadingView();
                }

                // The root page of your application
                MainPage = new NavigationPage(page)
                {
                    BarBackgroundColor = GetBackgroundColor()
                };
                if (!IsLogin)
                {
                    ValidateLoginAsync();
                }
            }
            catch
            {
                MainPage.DisplayAlert(T.GetValue("app_name"), T.GetValue("error_message"), T.GetValue("ok"));
            }
        }
示例#7
0
 public async Task DisplayAlertAsync(MessagesTexts messageKey)
 {
     await DisplayAlertAsync(T.GetValue(messageKey.ToString()));
 }
示例#8
0
 public async Task DisplayAlertAsync(string message)
 {
     await _page.DisplayAlert(T.GetValue("app_name"), message, T.GetValue("ok"));
 }
示例#9
0
        public ReservationCreateViewModel(Page page, ReservationModel reservation) : base(page)
        {
            User                    = new UserModel();
            IdUser                  = -1;
            _reservation            = reservation;
            ReservationButtonStatus = true;

            DoReservationCommand = new Command(async() =>
            {
                bool result = await UserValidations();
                if (!result)
                {
                    return;
                }

                ReservationButtonStatus = false;
                IsBusy = true;

                try
                {
                    if (IdUser == -1)
                    {
                        IdUser = await RestService.Instance.CreateUserOfflineAsync(User);
                    }
                    if (IdUser != -1)
                    {
                        if (Value < 1)
                        {
                            if (!await page.DisplayAlert(T.GetValue("app_name"), string.Format(T.GetValue("reservation_with_price_zero"), Value), T.GetValue("ok"), T.GetValue("cancel")))
                            {
                                ReservationButtonStatus = true;
                                IsBusy = false;
                                return;
                            }
                        }


                        int response;
                        _reservation.User = new UserModel {
                            IdUser = IdUser
                        };
                        _reservation.Price       = Value;
                        _reservation.Description = Description;

                        if (_reservation.Pitch.PitchType == PitchType.Multiple)
                        {
                            response = await RestService.Instance.DoReservationMultipleCustomerAsync(_reservation, IdUserType);
                        }
                        else
                        {
                            response = await RestService.Instance.DoReservationSingleCustomerAsync(_reservation, IdUserType);
                        }

                        if (response == -1)
                        {
                            await DisplayAlertAsync(MessagesTexts.reservation_conflict);
                        }
                        else
                        {
                            ReservationService.HasChanges                = true;
                            ReservationService.Reservation.Status        = ReservationStatus.Pending;
                            ReservationService.Reservation.IdReservation = response;

                            await DisplayAlertAsync(MessagesTexts.reservation_ok);
                            await _navigation.PopAsync();
                        }
                    }
                    else
                    {
                        await DisplayAlertAsync(MessagesTexts.error_message);
                        ReservationButtonStatus = true;
                    }
                }
                catch
                {
                    await DisplayAlertAsync(MessagesTexts.error_message);
                    ReservationButtonStatus = true;
                }

                IsBusy = false;
            });
            SearchCommand = new Command(async() =>
            {
                IsBusy = true;

                try
                {
                    List <UserModel> users = await RestService.Instance.SearchUsersAsync(Name);
                    if (users != null && users.Count != 0)
                    {
                        int consecutive = 0;

                        // Se agrega consecutivo ya que opcion que se usa para mostrar resultado retorna texto siempre
                        var data      = (from u in users select string.Concat((consecutive = consecutive + 1), ". ", u.Name)).ToArray();
                        string result = await _page.DisplayActionSheet(T.GetValue("app_name"), T.GetValue("ok"), null, data);

                        if (result != null && result != T.GetValue("ok"))
                        {
                            int pos        = Convert.ToInt32(result.Split(new char[] { '.' }, 2)[0]);
                            UserModel user = users[pos - 1];
                            Name           = user.Name;
                            Phone          = user.Phone;
                            Mail           = user.Mail;
                            IdUser         = user.IdUser;
                            IdUserType     = user.IdUserType;
                        }
                    }
                    else
                    {
                        await DisplayAlertAsync(MessagesTexts.search_without_data);
                    }
                }
                catch
                {
                    await DisplayAlertAsync(MessagesTexts.error_message);
                }

                IsBusy = false;
            });

            GetPitchPrice();
        }
示例#10
0
        public ReservationSummaryViewModel(Page page, ReservationModel reservation, bool loadReservationData) : base(page)
        {
            ReservationStatusId      = -1;
            ChangeStatusButtonStatus = true;
            _reservation             = reservation;

            ChangeStatusCommand = new Command(async() =>
            {
                ChangeStatusButtonStatus = false;
                IsBusy = true;

                try
                {
                    if (Reservation.Price < 1)
                    {
                        if (!await page.DisplayAlert(T.GetValue("app_name"), string.Format(T.GetValue("reservation_with_price_zero"), Reservation.Price), T.GetValue("ok"), T.GetValue("cancel")))
                        {
                            ChangeStatusButtonStatus = true;
                            IsBusy = false;
                            return;
                        }
                    }

                    _reservation.Status = GetStatusCode();
                    var response        = await RestService.Instance.ReservationUpdateAsync(_reservation);

                    if (response)
                    {
                        if (ReservationService.Reservation != null)
                        {
                            // Proceso para responder al Scheduler
                            ReservationService.HasChanges         = true;
                            ReservationService.Reservation.Status = GetReservationStatus();
                        }
                        else
                        {
                            // Proceso para responder a la lista de pendientes
                            if (ReservationStatusId != 0)
                            {
                                ReservationService.HasChanges = true;
                            }
                        }

                        await DisplayAlertAsync(MessagesTexts.change_status_ok);
                        await _navigation.PopAsync();
                    }
                    else
                    {
                        await DisplayAlertAsync(MessagesTexts.error_message);
                    }
                }
                catch { await DisplayAlertAsync(MessagesTexts.error_message); }

                IsBusy = false;
            });
            RetryCommand = new Command(() => { LoadReservationData(); });

            if (loadReservationData)
            {
                LoadReservationData();
            }
            else
            {
                Reservation = reservation;
                SetStatusCode();
            }
        }