Exemple #1
0
        private async Task RefreshPartiesFromDataBase()
        {
            manager           = AzurePartyManager.DefaultManager;
            mapCenterPosition = _map.VisibleRegion.Center;
            zoom    = _map.VisibleRegion.Radius.Kilometers;
            parties = await manager.GetCarouselItemsAsync(
                await manager.GetPartiesFromLocationAsync(
                    mapCenterPosition.Latitude,
                    mapCenterPosition.Longitude,
                    zoom * 1000 * 2));

            PlacePoints();
        }
Exemple #2
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);
        }