public async Task <IEnumerable <FriendsListJunctionModel> > GetAllUserFriends(int userId) { if (_validationService.IsNull(userId)) { try { return(await _friendListRepo.GetAllUserFriends(userId)); } catch { return(null); } } return(null); }
//get avg number of friends our users have.. public async Task <int> GetAvgFriends() { IEnumerable <UserAccountModel> models = await _userAccountRepository.GetAllAccounts(); List <int> friendcount = new List <int>(); foreach (var model in models) { IEnumerable <FriendsListJunctionModel> friendsListJunctionModel = await _friendListRepo.GetAllUserFriends(model.Id); friendcount.Add(friendsListJunctionModel.Count()); } int total = 0; foreach (int i in friendcount) { total += i; } int avg = total / friendcount.Count(); return(avg); }