Пример #1
0
 //Slet aktivity
 public async void SelfDestruct()
 {
     await Task.Run(async() =>
     {
         foreach (var date in DatesID)
         {
             DatesPersistency.DeleteDateAsync(date);
         }
         await Task.Delay(TimeSpan.FromSeconds(1));
         ActivityPersistency.DeleteActivityAsync(this);
         UserCatalogSingleton.Instance.LoginUser.Activities.Remove(this);
     });
 }
Пример #2
0
        //Sletter en given bruger
        public async void DeleteUser()
        {
            int UserSpotInList = 0;
            await Task.Run(async() =>
            {
                foreach (var user in UserVM.UserCatalogSingleton.UserList)
                {
                    if (user == UserVM.SelectedUser)
                    {
                        foreach (var activity in user.Activities)
                        {
                            foreach (var dateids in activity.DatesID)
                            {
                                DatesPersistency.DeleteDateAsync(dateids);
                            }
                            ActivityPersistency.DeleteActivityAsync(activity);
                        }
                    }
                }
                await Task.Delay(TimeSpan.FromSeconds(1));
            });

            await Task.Run(async() =>
            {
                foreach (var user in UserVM.UserCatalogSingleton.UserList)
                {
                    if (user == UserVM.SelectedUser)
                    {
                        break;
                    }
                    UserSpotInList++;
                }
                await Task.Delay(TimeSpan.FromSeconds(1));
            });

            Debug.WriteLine(UserSpotInList);
            UserPersistency.DeleteEventsAsync(UserVM.SelectedUser);
            UserVM.UserCatalogSingleton.RemoveUser(UserVM.SelectedUser);
        }