示例#1
0
        public bool AddFavourite(int id)
        {
            string username = DBHandler.GetTempUsername(this);

            bool check = DBHandler.GetFavourites().Exists(x => x.LocationId.Equals(id) && x.Username.Equals(username));

            if (check)
            {
                Favourite oldFavourite = DBHandler.GetFavourites().FirstOrDefault((x => x.LocationId.Equals(id) && x.Username.Equals(username)));
                DBHandler.RemoveFavourite(oldFavourite);
                return(false);
            }
            else
            {
                Favourite newFavourite = new Favourite {
                    LocationId = id, Username = username
                };
                DBHandler.AddFavourite(newFavourite);
                return(true);
            }
        }