public async void DisplayResult()
        {
            var user = await UserDataStore.GetItemAsync("User1");

            HatResult = user.HatColour;
            DisplayDescription();
        }
Beispiel #2
0
        private async void Login_OnClicked(object sender, EventArgs e)
        {
            UserDataStore uds  = new UserDataStore();
            User          user = await uds.GetItemAsync(loginViewModel.Username);

            if (user != null && user.UserName.Length > 0)
            {
                if (loginViewModel.Password.Equals(user.Password))
                {
                    loginViewModel.LoggedOnUser = user.UserName + " you are now logged in.";
                    loginViewModel.Username     = "";
                    loginViewModel.Password     = "";
                    props.SetPropertyValue("UserLoggedInUser", user.UserName);
                    start_btn.IsVisible = true;

                    await Navigation.PushAsync(new MainPage());
                }
                else
                {
                    await App.Current.MainPage.DisplayAlert("Wrong Credentials", "Please Enter again", "OK");

                    loginViewModel.LoggedOnUser = "";
                    props.SetPropertyValue("UserLoggedInUser", "");
                    start_btn.IsVisible = false;
                }
            }
        }
Beispiel #3
0
        public async void OnQuizSubmitBlack(object obj)
        {
            var user1 = await UserDataStore.GetItemAsync("User1");

            QuestsCompleted1    = user1.QuestsCompleted;
            PersonalExperience1 = user1.PersonalExperience;
            User newUser = new User()
            {
                Name               = "User1",
                Username           = "******",
                Password           = null,
                PersonalExperience = PersonalExperience1 + 500,
                PartyExperience    = 2100,
                HatColour          = "Black", // This needs to be updated when hat quiz is completed

                //statistics
                QuestionsAnswered = 13,
                QuestsCompleted   = QuestsCompleted1,

                //trophygained
                Trophy5Gained = true,
                Trophy6Gained = false,
                Trophy7Gained = false,
                Trophy8Gained = false,
                Trophy9Gained = false,
            };
            await UserDataStore.UpdateItemAsync(newUser);

            await Shell.Current.GoToAsync($"{nameof(HatQuizResult)}");
        }
Beispiel #4
0
        protected async override void OnAppearing()
        {
            UserDataStore = new UserDataStore();
            var seller = await UserDataStore.GetItemAsync(Advertisement.UserId);

            BindingContext = AdViewModel = new AdvertismentViewModel {
                Advertisment = this.Advertisement, CurrentImageIndex = 0, FirebaseUser = seller
            };
            foreach (var imageUrl in AdViewModel.Advertisment.PicturesURL)
            {
                AdViewModel.ImageSources.Add(ImageSource.FromUri(new Uri(imageUrl)));
            }
        }
Beispiel #5
0
        public async void FillUserData()
        {
            var groups = await GroupDataStore.GetItemsAsync();

            var users = await UserDataStore.GetItemsAsync();

            foreach (var group in groups)
            {
                if (group.MemberId4 == "User1")
                {
                    //Add group data
                    GroupName = group.GroupName;
                    var result = ExperienceToLevel(group.GroupXP);
                    GroupLevel   = result.Item1.ToString();
                    GroupPercent = result.Item4;
                    //Add first user data
                    var user1 = await UserDataStore.GetItemAsync(group.MemberId1);

                    var result1 = ExperienceToLevel(user1.PersonalExperience);
                    User1Name    = user1.Username;
                    User1Level   = result1.Item1.ToString();
                    User1Percent = result1.Item4;
                    //Add second user data
                    var user2 = await UserDataStore.GetItemAsync(group.MemberId2);

                    var result2 = ExperienceToLevel(user2.PersonalExperience);
                    User2Name    = user2.Username;
                    User2Level   = result2.Item1.ToString();
                    User2Percent = result2.Item4;
                    //Add third user data
                    var user3 = await UserDataStore.GetItemAsync(group.MemberId3);

                    var result3 = ExperienceToLevel(user3.PersonalExperience);
                    User3Name    = user3.Username;
                    User3Level   = result3.Item1.ToString();
                    User3Percent = result3.Item4;
                    //Add fourth user data
                    var user4 = await UserDataStore.GetItemAsync(group.MemberId4);

                    var result4 = ExperienceToLevel(user4.PersonalExperience);
                    User4Name    = user4.Username;
                    User4Level   = result4.Item1.ToString();
                    User4Percent = result4.Item4;

                    break;
                }
            }
        }
Beispiel #6
0
        public User(ObjectId id)
        {
            var user = DataStore.GetItemAsync(id.ToString()).Result;

            this.Id        = user.Id;
            this.FirstName = user.FirstName;
            this.LastName  = user.LastName;
            this.Email     = user.Email;
            this.Password  = user.Password;
            this.FoodIds   = user.FoodIds;

            Foods = new Food[FoodIds.Count];
            for (int i = 0; i < FoodIds.Count; i++)
            {
                Foods[i] = new Food(FoodIds[i].AsBsonDocument);
            }
        }
Beispiel #7
0
        public async void FillGroupData()
        {
            var groups = await GroupDataStore.GetItemsAsync();

            Groups[] GroupArray = groups.ToArray();

            // Fill group 1 data
            var group1 = await GroupDataStore.GetItemAsync(GroupArray[0].GroupName);

            GroupName_1 = group1.GroupName;
            var user1_1 = await UserDataStore.GetItemAsync(group1.MemberId1);

            User1_1Name = user1_1.Username;
            User1_1Hat  = user1_1.HatColour.ToLower();
            var user1_2 = await UserDataStore.GetItemAsync(group1.MemberId2);

            User1_2Name = user1_2.Username;
            User1_2Hat  = user1_2.HatColour.ToLower();
            var user1_3 = await UserDataStore.GetItemAsync(group1.MemberId3);

            User1_3Name = user1_3.Username;
            User1_3Hat  = user1_3.HatColour.ToLower();
            // Fill group 2 data
            var group2 = await GroupDataStore.GetItemAsync(GroupArray[1].GroupName);

            GroupName_2 = group2.GroupName;
            var user2_1 = await UserDataStore.GetItemAsync(group2.MemberId1);

            User2_1Name = user2_1.Username;
            User2_1Hat  = user2_1.HatColour.ToLower();
            var user2_2 = await UserDataStore.GetItemAsync(group2.MemberId2);

            User2_2Name = user2_2.Username;
            User2_2Hat  = user2_2.HatColour.ToLower();
            var user2_3 = await UserDataStore.GetItemAsync(group2.MemberId3);

            User2_3Name = user2_3.Username;
            User2_3Hat  = user2_3.HatColour.ToLower();
        }
        public async void UpdateUser()
        {
            var user1 = await UserDataStore.GetItemAsync("User1");

            HatUser1            = user1.HatColour;
            PersonalExperience1 = user1.PersonalExperience;
            QuestionsAnswered1  = user1.QuestionsAnswered;
            QuestsCompleted1    = user1.QuestsCompleted;
            User newUser = new User()
            {
                Id                 = Guid.NewGuid().ToString(),
                Name               = "User1",
                Username           = "******",
                Password           = null,
                PersonalExperience = PersonalExperience1 + 200,
                PartyExperience    = 2100,
                HatColour          = HatUser1,

                //statistics
                QuestionsAnswered            = QuestionsAnswered1 + 4,
                QuestsCompleted              = QuestsCompleted1 + 1,
                CommentsPosted               = 3,
                AverageQuizAccuracy          = 99,
                AverageTimeTakenEachActivity = 23,

                //trophygained
                Trophy1Gained = false,
                Trophy2Gained = true,
                Trophy3Gained = true,
                Trophy4Gained = true,
                Trophy5Gained = true,
                Trophy6Gained = user1.Trophy6Gained,
                Trophy7Gained = false,
                Trophy8Gained = false,
                Trophy9Gained = false
            };
            await UserDataStore.UpdateItemAsync(newUser);
        }
Beispiel #9
0
        public async void OnGroup2Clicked(object obj)
        {
            Quest newItem = new Quest()
            {
                Id         = "group1",
                Status     = "complete",
                Type       = "group",
                Name       = "Complete the Six Hats Quiz",
                Topic      = "Group",
                Experience = 500,
                QuestDate  = DateTime.Now
            };
            await QuestDataStore.UpdateItemAsync(newItem);

            var user1 = await UserDataStore.GetItemAsync("User1");

            HatUser1            = user1.HatColour;
            PersonalExperience1 = user1.PersonalExperience;
            QuestionsAnswered1  = user1.QuestionsAnswered;
            QuestsCompleted1    = user1.QuestsCompleted;
            User newUser = new User()
            {
                Id                 = Guid.NewGuid().ToString(),
                Name               = "User1",
                Username           = "******",
                Password           = null,
                PersonalExperience = PersonalExperience1,
                PartyExperience    = 0 + 500,
                HatColour          = HatUser1,

                //statistics
                QuestionsAnswered            = 75,
                QuestsCompleted              = user1.QuestsCompleted + 1,
                CommentsPosted               = 3,
                AverageQuizAccuracy          = 99,
                AverageTimeTakenEachActivity = 23,

                //trophygained
                Trophy1Gained = false,
                Trophy2Gained = true,
                Trophy3Gained = true,
                Trophy4Gained = true,
                Trophy5Gained = true,
                Trophy6Gained = true,
                Trophy7Gained = false,
                Trophy8Gained = false,
                Trophy9Gained = false
            };
            await UserDataStore.UpdateItemAsync(newUser);

            Groups newGroup = new Groups()
            {
                Id        = Guid.NewGuid().ToString(),
                GroupName = "Crescent Regiment",
                MemberId1 = "User5",
                MemberId2 = "User6",
                MemberId3 = "User7",
                MemberId4 = "User1",
                GroupXP   = 600 + 500
            };
            await GroupDataStore.UpdateItemAsync(newGroup);

            //Display an alert
            await App.Current.MainPage.DisplayAlert("Your journey begins...", "You've joined a party! View the My Party tab for your party progress.", "Continue");

            MessagingCenter.Send <PartySelectionViewModel>(this, "popped");

            await Shell.Current.Navigation.PopToRootAsync().ConfigureAwait(true);

            //await Shell.Current.GoToAsync(nameof(QuestLog));
        }