コード例 #1
0
        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;
        }
コード例 #2
0
 public void RemoveApartment(Apartment apartment)
 {
     Apartments.Remove(apartment);
 }
コード例 #3
0
 public void RemoveApartments(Apartment apr)
 {
     Apartments.Remove(apr);
 }