Beispiel #1
0
        public async Task <List <PartyDetailsItem> > GetPartiesUserIsHostingAsync()
        {
            List <PartyDetailsItem> tempCarouselList = new List <PartyDetailsItem>();
            List <PartyDetails>     tempPartyList    = new List <PartyDetails>();

            //Query databse for parties user is hosting
            try
            {
                var query = client.CreateDocumentQuery <PartyDetails>(collectionLink, new FeedOptions {
                    MaxItemCount = -1, EnableScanInQuery = true
                })
                            .Where(party => party.userId == App.UserDetails.userId) //1 = 1m
                            .AsDocumentQuery();
                tempPartyList = new List <PartyDetails>();
                while (query.HasMoreResults)
                {
                    tempPartyList.AddRange(await query.ExecuteNextAsync <PartyDetails>());
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("$[Query]" + ex.Message);
            }
            //Convert parties to CarouselParties
            foreach (var item in tempPartyList)
            {
                PartyDetailsItem tempParty = new PartyDetailsItem(item);
                await tempParty.InitializeCard();

                tempParty.isThisUserHosting = true;
                tempParty.joinButtonLabel   = Constants.joinButtonTitles[(int)Constants.JoinedPartyStates.CancelEvent];
                tempCarouselList.Add(tempParty);
            }
            return(tempCarouselList);
        }
Beispiel #2
0
 public async void GoToParties(Object sender, EventArgs args, PartyDetailsItem selectedParty)
 {
     //PartyHelper.SortPartyByIndex(index);
     manager.SortCarouselPartiesToIndex(selectedParty.index);
     Debug.WriteLine("Pin Pressed");
     var carouselPage = new PartyCarouselPage();
     await Navigation.PushModalAsync(carouselPage);
 }
Beispiel #3
0
        public async Task <List <PartyDetailsItem> > GetCarouselItemsAsync(List <PartyDetails> partyList)
        {
            if (partyList == null || partyList.Count < 1)
            {
                await Application.Current.MainPage.DisplayAlert("Alert!", "No Parties Found", "OK");

                throw new NullReferenceException();
            }
            //First convert parties to CarouselParties
            List <PartyDetailsItem> tempCarouselList = new List <PartyDetailsItem>();

            foreach (var item in partyList)
            {
                PartyDetailsItem tempItem = new PartyDetailsItem(item);
                await tempItem.InitializeCard();

                tempItem.index = tempCarouselList.Count;
                tempCarouselList.Add(tempItem);
            }

            //Get Table with attendee details
            var cloudService = ServiceLocator.Instance.Resolve <ICloudService>();
            ICloudTable <AttendeeDetails> Table = cloudService.GetTable <AttendeeDetails>();


            //Find out which parties the user is attending
            try
            {
                //var searchResults = await App.UserDetailsUserIdSearchIndexClient.Documents.SearchAsync<AttendeeDetails>(App.userDetails.Id);
                //ObservableRangeCollection<PartyDetails> partiesAttending = PartiesAttending;
                //ObservableRangeCollection<PartyDetails> partiesHosting = PartiesHosting;
                //
                //if (partiesAttending != null && partiesAttending.Count > 0)
                //{
                //    var myParties = from m in tempCarouselList
                //                    let fr = (from f in partiesAttending select f.partyId)
                //                    where fr.Contains(m.partyId)
                //                    select m.isThisUserAttending == true;
                //    //myParties;
                //}
                //
                //if (partiesHosting != null && partiesHosting.Count > 0)
                //{
                //    var myParties = from m in tempCarouselList
                //                    let fr = (from f in partiesHosting select f.userId)
                //                    where fr.Contains(App.userDetails.userId)
                //                    select m.isThisUserHosting = true;
                //    //myParties;
                //}

                //User found for every match make party special
            }catch (Exception ex)
            {
                Console.WriteLine($"[Login] Error = {ex.Message}");
            }
            CarouselItems = tempCarouselList;
            return(tempCarouselList);
        }
Beispiel #4
0
 private void InitializePartyCard(PartyDetailsItem partyDetailsItem)
 {
     Icon            = partyDetailsItem.hostpicture;
     BackgroundImage = partyDetailsItem.pictureImageSource;
     Title           = partyDetailsItem.title;
     subTitle        = partyDetailsItem.when.ToString();
     LeftDetail      = LocationHelper.distance(partyDetailsItem.latt, partyDetailsItem.lon, App.CurrentPosition.Latitude, App.CurrentPosition.Longitude, 'K').ToString();
     RightDetail     = "DKK" + partyDetailsItem.price;
 }
        async Task RefreshPage(object sender, int index)
        {
            selectedTab = index;
            //CardListView senderListView = (CardListView)sender;

            var cloudService = ServiceLocator.Instance.Resolve <ICloudService>();
            ICloudTable <PartyDetails> table   = cloudService.GetTable <PartyDetails>();
            ICollection <PartyDetails> parties = await cloudService.RetreivePartiesWithinRange(searchPosition.Longitude, searchPosition.Latitude, Constants.defaultSearchRange, index);

            ObservableRangeCollection <CardListItem> sortedItems = new ObservableRangeCollection <CardListItem>();

            foreach (var item in parties)
            {
                PartyDetailsItem tempItem = new PartyDetailsItem(item);
                await tempItem.InitializeCard();

                CardListItem temp = new CardListItem()
                {
                    partyDetailsItem = tempItem
                };
                sortedItems.Add(temp);
            }
            ((CardListView )_items[index]).ItemsSource = sortedItems;
        }
Beispiel #6
0
        private async Task <List <PartyDetailsItem> > GetPartiesFromDataBase(Position position)
        {
            manager = AzurePartyManager.DefaultManager;
            await manager.DeleteAllBuggedPartiesAsync();

            TaskCompletionSource <List <PartyDetailsItem> > tcs = new TaskCompletionSource <List <PartyDetailsItem> >();
            List <PartyDetails> partydetails = await manager.GetPartiesFromLocationAsync(
                position.Latitude,
                position.Longitude,
                30000);


            List <PartyDetailsItem> partyDetailsItems = new List <PartyDetailsItem>();

            foreach (var item in partydetails)
            {
                PartyDetailsItem tempItem = new PartyDetailsItem(item);
                await tempItem.InitializeCard();

                partyDetailsItems.Add(tempItem);
            }
            tcs.SetResult(partyDetailsItems);
            //parties = manager.GetCarouselItemsAsync(partydetailDB).Result;

            //if (parties == null || !parties.Any())
            //{
            //    ICloudTable<PartyDetails> Table;
            //    ICloudService cloudService = ServiceLocator.Instance.Resolve<ICloudService>();
            //    Table = cloudService.GetTable<PartyDetails>();
            //    ICollection<PartyDetails> tempPartyDetails = await Table.ReadAllItemsAsync();
            //
            //    List<PartyDetailsDB> tempPartyDetailsDB = new List<PartyDetailsDB>();
            //    foreach(PartyDetails deet in tempPartyDetails)
            //    {
            //        PartyDetailsDB tempDeetDB = new PartyDetailsDB {
            //            title = deet.title,
            //            description = deet.description,
            //            partyId = deet.partyId,
            //            userId = deet.userId,
            //            picture = deet.picture,
            //            ageMax = deet.ageMax,
            //            ageMin = deet.ageMin,
            //            rating = deet.rating,
            //            price = deet.price,
            //            when = deet.when,
            //            where = deet.where,
            //            type = deet.type,
            //            lon = deet.lon,
            //            latt = deet.latt,
            //            maxParticipants = deet.maxParticipants,
            //            documentDBId = deet.Id,
            //            location = new Microsoft.Azure.Documents.Spatial.Point(deet.lon, deet.latt)
            //        };
            //        tempPartyDetailsDB.Add(tempDeetDB);
            //    }
            //
            //    await Task.WhenAll(tempPartyDetailsDB.Select(q => manager.InsertItemAsync(q)));
            //    await manager.DeleteAllBuggedPartiesAsync();
            //    parties = await manager.GetCarouselItemsAsync(await manager.GetAllPartiesAsync());
            //}
            return(await tcs.Task);
        }
 public async void ClickedEventHandler(object sender, EventArgs e)
 {
     await PartyDetailsItem.ExecuteJoinPartyCommand();
 }