Exemple #1
0
 public async Task <bool> DeleteReservation(Reservations reserv)
 {
     if (IsBusy)
     {
         return(false);
     }
     IsBusy = true;
     return(await Task.Run(async() =>
     {
         try
         {
             System.Net.HttpStatusCode res = await _reservationsController.DeleteByID(reserv.ID);
             if (res == System.Net.HttpStatusCode.OK)
             {
                 Toast = "Successfully deleted";
                 Reservations.Remove(reserv);
                 AvailableReservations.Remove(reserv);
                 return true;
             }
         }
         catch (Exception e)
         {
             ErrorDialog(e.Message, "Task faild");
         }
         finally
         {
             IsBusy = false;
         }
         return true;
     }));
 }
Exemple #2
0
        public async Task <bool?> Login(string email, string hash)
        {
            IsBusy = true;
            return(await Task.Run(new Func <bool?>(() =>
            {
                try
                {
                    IEnumerable <People> list = _peopleController.GetAllEntries().Result;
                    if (list == null)
                    {
                        ErrorDialog("No user found please register", "login failed");
                        return null;
                    }
                    foreach (People item in list)
                    {
                        if (item.Email?.ToLower() == email?.ToLower())
                        {
                            if (item.PasswordHash != hash)
                            {
                                ErrorDialog("Wrong password", "login failed");
                                return false;
                            }
                            Services.LocalData.SaveLoginInfo(item);

                            IsBusy = false;
                            IsLoggedIn = true;
                            CurrentLoginInfo = item;
                            Reservations.Clear();
                            AvailableReservations.Clear();
                            //Initialize();
                            Toast = "Loading";
                            RecordEvent("Login", "Login detected on device " + ServicesInterfaces.GetDeviceServices()?.GetDeviceName());

                            return true;
                        }
                    }
                    ErrorDialog("No account found please register", "login faild");
                    return null;
                }
                catch (Exception e)
                {
                    ErrorDialog("Please check you network \n" + e.Message, "connection faild");

                    return false;
                }
                finally
                {
                    IsBusy = false;
                }
            })));
        }
Exemple #3
0

        
Exemple #4
0
 public async Task RefreshReservations(bool silent = false)
 {
     if (IsLoadingResrvations)
     {
         return;
     }
     IsLoadingResrvations = silent ? false : true;;
     await Task.Run(async() =>
     {
         try
         {
             List <Reservations> reservations = (await _reservationsController.GetAllEntries())?.Where(r => r.Person_Id == CurrentLoginInfo.ID)?.ToList();
             if (reservations == null || reservations?.Count <= 0)
             {
                 if (!silent)
                 {
                     Toast = "No reservations available";
                 }
             }
             else
             {
                 Reservations.AddRange(reservations, true);
                 AvailableReservations.AddRange(reservations.Where(r => r.IsAvailable), true);
             }
         }
         catch (Exception e)
         {
             if (!silent)
             {
                 Toast = "Bad network \n" + e.Message;
             }
         }
         finally
         {
             IsLoadingResrvations = false;
         }
     });
 }