From d72c84ef5f0469515b9935297d4290141e8eefc0 Mon Sep 17 00:00:00 2001 From: Max Mannstein Date: Tue, 22 Jul 2025 18:38:26 +0200 Subject: [PATCH] Sort walkers by distance, photo presence, and average rating in HomeViewModel --- gehGassiApp/gehGassiApp/ViewModels/HomeViewModel.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/gehGassiApp/gehGassiApp/ViewModels/HomeViewModel.cs b/gehGassiApp/gehGassiApp/ViewModels/HomeViewModel.cs index 6077d4f..04be5ac 100644 --- a/gehGassiApp/gehGassiApp/ViewModels/HomeViewModel.cs +++ b/gehGassiApp/gehGassiApp/ViewModels/HomeViewModel.cs @@ -539,7 +539,12 @@ namespace gehGassiApp.ViewModels request.Distance = Location.CalculateDistance(CurrentLocation.Lat.Value, CurrentLocation.Lng.Value, request.Lat, request.Lng, DistanceUnits.Kilometers); } - Walkers = requests.Value.ToObservableCollection(); + // Sortierung: Entfernung, dann mit Foto, dann mit Rating + Walkers = requests.Value + .OrderBy(x => x.Distance) + .ThenByDescending(x => !string.IsNullOrWhiteSpace(x.Photo)) + .ThenByDescending(x => x.AverageRating > 0) + .ToObservableCollection(); _total = requests.Total; _skip = requests.Skip + requests.Take;