Exemplo n.º 1
0
        async Task GetListingsModels(ListingsModelsSearchRequest request)
        {
            listings.Clear();

            var list = await APIService.GetListingsModels(request);

            foreach (var item in list)
            {
                listings.Add(item);
            }
            lvListings.ItemsSource = listings;
        }
Exemplo n.º 2
0
 public TraziPage(ListingsModelsSearchRequest request)
 {
     InitializeComponent();
     _request        = new ListingsModelsSearchRequest();
     _request        = request;
     _searchText     = "";
     listings        = new ObservableCollection <Model.ListingModel>();
     this.Appearing += async(object sender, EventArgs e) =>
     {
         await GetListingsModels(_request);
     };
 }
Exemplo n.º 3
0
 public HomePage(ListingsModelsSearchRequest request)
 {
     InitializeComponent();
     this.Children.Add(new MojDomPage()
     {
         Title = "Moj dom"
     });
     this.Children.Add(new TraziPage(request)
     {
         Title = "Traži"
     });
     this.Children.Add(new ProfilPage()
     {
         Title = "Profil"
     });
     this.CurrentPage = this.Children[1];
 }
        private async void BtnFilter_Clicked(object sender, EventArgs e)
        {
            var request = new ListingsModelsSearchRequest();

            request.City        = EntCity.Text;
            request.TerritoryId = territoryId;
            request.Persons     = (int)Math.Round(sPersons.Value / StepValue);
            request.Beds        = (int)Math.Round(sBeds.Value / StepValue);
            request.Bathrooms   = (int)Math.Round(sBathrooms.Value / StepValue);
            request.Amenities   = new List <int>();

            var selectedAmenities = AmenitiesItems.SelectedItems().ToList();

            foreach (var item in selectedAmenities)
            {
                request.Amenities.Add(item.Data.AmenityId);
            }
            await Navigation.PushAsync(new HomePage(request));
        }
Exemplo n.º 5
0
        private async Task LoadListings(int listingId)
        {
            ListingsModelsSearchRequest request = new ListingsModelsSearchRequest();

            request.Amenities = null;
            List <Model.ListingModel> listingsList = await APIService.GetListingsModels(request);

            var listingToRemove = listingsList.Find(x => x.ListingId == listingId);

            listingsList.Remove(listingToRemove);

            List <Rating> ratings = new List <Rating>();

            foreach (var item in listingsList)
            {
                ratings = await APIService.GetRatingsByListing(item.ListingId);

                if (ratings != null)
                {
                    ratings = ratings.OrderBy(x => x.UserId).ToList();
                    listings.Add(item.ListingId, ratings);
                }
            }
        }
Exemplo n.º 6
0
        public List <ListingModel> GetListingsModels(ListingsModelsSearchRequest request)
        {
            var query = _context.Listing
                        .Include(x => x.ListingImages)
                        .Where(x => x.Approved)
                        .Where(x => x.UserId != request.UserId)
                        .AsQueryable();

            if (!string.IsNullOrWhiteSpace(request.City))
            {
                query = query.Where(x => x.City.StartsWith(request.City));
            }
            if (request.TerritoryId != null && request.TerritoryId != -1)
            {
                query = query.Where(x => x.TerritoryId == request.TerritoryId);
            }
            if (request.Persons != null && request.Persons != 0)
            {
                query = query.Where(x => x.Persons == request.Persons);
            }
            if (request.Beds != null && request.Beds != 0)
            {
                query = query.Where(x => x.Beds == request.Beds);
            }
            if (request.Bathrooms != null && request.Bathrooms != 0)
            {
                query = query.Where(x => x.Bathrooms == request.Bathrooms);
            }

            var list = query.ToList();

            list = list.OrderByDescending(x => x.DateApproved).ToList();
            if (request.Amenities != null && request.Amenities.Count > 0)
            {
                try
                {
                    for (int i = list.Count - 1; i >= 0; i--)
                    //foreach (var listing in list)
                    {
                        var listing = list[i];
                        foreach (var amenity in request.Amenities)
                        {
                            if (!_context.ListingAmenity
                                .Any(x => x.ListingId == listing.ListingId && x.AmenityId == amenity))
                            {
                                list.Remove(listing);
                                break;
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Debug.WriteLine(ex.Message);
                }
            }


            List <Model.ListingModel> result = new List <ListingModel>();

            foreach (var item in list)
            {
                var newListingModel = new Model.ListingModel
                {
                    Bathrooms = item.Bathrooms,
                    Beds      = item.Beds,
                    Persons   = item.Persons,
                    City      = item.City,
                    Name      = item.Name,
                    ListingId = item.ListingId
                };
                //mapping images
                if (_context.ListingImage.Any(x => x.ListingId == item.ListingId))
                {
                    newListingModel.Image = _context.ListingImage.FirstOrDefault(x => x.ListingId == item.ListingId).Image;
                }

                result.Add(newListingModel);
            }

            return(result);
        }
Exemplo n.º 7
0
 public ActionResult <List <Model.ListingModel> > GetListingsModels(ListingsModelsSearchRequest request)
 {
     return(_service.GetListingsModels(request));
 }