Esempio n. 1
0
        public void OnGet(int beerId)
        {
            //passed a beer id
            string userId = User.FindFirst(ClaimTypes.NameIdentifier).Value;

            friendsList = new List <friends>();

            selectedBeer = _beerRepository.getBeerById(beerId);

            //do YOU need it -> is the beer id in getUserCollection?
            //https://stackoverflow.com/questions/1071032/searching-if-value-exists-in-a-list-of-objects-using-linq
            haveIHadTheBeer = _beerCollectionRepository.getUserCollection(userId).Any(beer => beer.beer_id == beerId);

            //do your friends need it? GetFriends (list of friends)
            friendsList = _friendRepository.GetFriends(userId);

            Results = new List <friends>();
            foreach (var friend in friendsList)
            {
                bool haveTheyHadTheBeer = _beerCollectionRepository.getUserCollection(friend.friend_id).Any(beer => beer.unique_id == selectedBeer.unique_id);

                if (!haveTheyHadTheBeer)
                {
                    Results.Add(friend);
                }
            }
            //for each friend check collectionViewModel to see if the unique beer id is present.
            // one method in this page model, to call the service which will do this work and return...  list of friends who need it.
        }
Esempio n. 2
0
        public async Task <ObjectResponse> GetFriends(string id)
        {
            ObjectResponse ob = new ObjectResponse();

            ob = await _friendrespository.GetFriends(id);

            return(ob);
        }
Esempio n. 3
0
 public void OnGet()
 {
     currentUser = User.FindFirst(ClaimTypes.NameIdentifier).Value;
     friendList  = _friendRespository.GetFriends(currentUser);
 }
Esempio n. 4
0
 public List <friends> GetFriends(string userId)
 {
     return(_friendRespository.GetFriends(userId));
 }