private ClientCardViewModel GetClientCard(User user, Specialist specialist) { var result = new ClientCardViewModel { ID = user.ID, User = new UserViewModel(user), ProblemsCount = ProblemService.GetUserProblemsCount(user), }; var sessions = SessionService.GetAll() .Where(x => x.Problem.User == user && x.Specialist == specialist) .OrderByDescending(x => x.Date) .ToList(); var reviews = new List <ReviewViewModel>(); sessions.ForEach(session => { var review = ReviewService.GetSessionReview(session); reviews.Add(new ReviewViewModel(review)); }); result.Sessions = sessions.Select(x => GetSpecialistSession(x)).ToList(); result.AverageScore = (reviews.Sum(x => x.Score) / reviews.Count); result.Paid = sessions.Where(x => x.Status == SessionStatus.Success).Sum(x => x.Reward); result.RefundsCount = sessions.Where(x => x.Status == SessionStatus.Refund).ToList().Count; return(result); }