Пример #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.
        }
Пример #2
0
 public List <beersViewModel> getUserCollection(string userId)
 {
     return(_beerCollectionRepository.getUserCollection(userId));
 }