Пример #1
0
        /// <summary>
        /// Wczytywanie historii ofert
        /// </summary>
        public async void Load()
        {
            var ret = new ObservableCollection <DisplayableOffer>();

            //nazwa aktualnego usera
            string currentUser = Thread.CurrentPrincipal.Identity.Name;

            //wyslij zapytanie o akutualnego usera
            User user = await usersProxy.GetUser(currentUser);

            //wyslij zapytanie o listę ofert
            var list = await offersProxy.GetUserHistoricalOffers(user.Id);

            //Dla każdej oferty w historii stwórz jej wersję do wyświetlenia
            foreach (var item in list)
            {
                OfferInfo oi = await offerInfoesProxy.Get(item.OfferInfoId);

                Room r = await roomsProxy.Get(item.RoomId);

                Place p = await placesProxy.Get(r.PlaceId);

                Address a = await addressesProxy.Get(p.AddressId);

                p.Address      = a;
                r.Place        = p;
                item.OfferInfo = oi;
                item.Room      = r;
                DisplayableOffer dof = new DisplayableOffer(item);
                ret.Add(dof);
            }

            this.CurrentOffersList = ret;
        }
        public async void Load()
        {
            var ret = new ObservableCollection <DisplayableOffer>();

            string currentUser = Thread.CurrentPrincipal.Identity.Name;

            User user = await usersProxy.GetUser(currentUser);

            var list = await offersProxy.GetUserOffers(user.Id);

            foreach (var item in list)
            {
                OfferInfo oi = await offerInfoesProxy.Get(item.OfferInfoId);

                Room r = await _roomsProxy.Get(item.RoomId);

                Place p = await PlacesProxy.Get(r.PlaceId);

                Address a = await addressesProxy.Get(p.AddressId);

                p.Address      = a;
                r.Place        = p;
                item.OfferInfo = oi;
                item.Room      = r;
                DisplayableOffer dof = new DisplayableOffer(item);
                ret.Add(dof);
            }

            this.CurrentOffersList = ret;
        }
        private async Task Load()
        {
            var    coll     = new ObservableCollection <DisplayableOfferViewModel>();
            string username = Thread.CurrentPrincipal.Identity.Name;

            //using (var context = new AccommodationContext())
            //{
            //    User u = context.Users.FirstOrDefault(us => us.Username.Equals(username));
            //    if (u == null) throw new Exception();
            //    IEnumerable<Offer> offers =
            //        context.Offers.Where(o => o.CustomerId == u.Id)
            //            .Include(o => o.OfferInfo)
            //            .Include(o => o.Room.Place)
            //            .Include(o => o.Room.Place.Address);
            //    foreach (var offer in offers)
            //    {
            //        coll.Add(new DisplayableOfferViewModel(new DisplayableOffer(offer)));
            //    }
            //}
            try
            {
                IList <Offer> offers = await _offersProxy.GetReservedOffers(username);

                foreach (var offer in offers)
                {
                    offer.OfferInfo = await _offerInfoesProxy.Get(offer.OfferInfoId);

                    offer.Room = await _roomsProxy.Get(offer.RoomId);

                    offer.Room.Place = await _placesProxy.Get(offer.Room.PlaceId);

                    offer.Room.Place.Address = await _addressesProxy.Get(offer.Room.Place.AddressId);
                }
                foreach (var offer in offers)
                {
                    var vm = new DisplayableOfferViewModel(new DisplayableOffer(offer));
                    coll.Add(vm);
                    vm.OfferResigned += OnResign;
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Nie udało się załodować ofert.");
            }
            PurchasedOffers = coll;
        }
Пример #4
0
        public async Task SearchResultAsync()
        {
            try
            {
                IEnumerable <Offer> offers = await SearchAsync();

                foreach (var offer in offers)
                {
                    Room r = await _roomsProxy.Get(offer.RoomId);

                    Place p = await _placesProxy.Get(r.PlaceId);

                    OfferInfo oi = await _oiProxy.Get(offer.OfferInfoId);

                    Address a = await _addressProxy.Get(p.AddressId);

                    p.Address        = a;
                    offer.Room       = r;
                    offer.Room.Place = p;
                    offer.OfferInfo  = oi;
                }
                SearchingResults = offers.Select(o => new DisplayableOfferViewModel(new DisplayableOffer(o)));
                foreach (var displayableOfferViewModel in SearchingResults)
                {
                    displayableOfferViewModel.OfferReserved += (x, e) => OnOfferReserved(x, e);
                }
            }
            catch (Exception)
            {
                MessageDialog md = new MessageDialog()
                {
                    Title = "Błąd", Message = "Błąd systemu wyszukiwania"
                };
                md.ShowDialog();
            }
        }