public async Task ManageFavorite(Apartment apartment) { Loading = true; if (apartment.IsFavorite) { apartment.IsFavorite = false; var favorite = DataService.Favorites.FirstOrDefault(x => x.ApartmentId == apartment.Id); await DataService.SyncFavorites.DeleteAsync(favorite); DataService.Favorites.Remove(favorite); Apartments.Remove(apartment); } else { apartment.IsFavorite = true; var favorite = new Favorite { Id = Guid.NewGuid().ToString(), UserId = DataService.User.Id, ApartmentId = apartment.Id }; await DataService.SyncFavorites.InsertAsync(favorite); DataService.Favorites.Add(favorite); } await DataService.SyncApartments.UpdateAsync(apartment); Loading = false; }
public void RemoveApartment(Apartment apartment) { Apartments.Remove(apartment); }
public void RemoveApartments(Apartment apr) { Apartments.Remove(apr); }