Beispiel #1
0
        public TraineeProfileDTO Info(string login)
        {
            TraineeProfileService service = new TraineeProfileService(services);
            TraineeProfileDTO     result  = service.GetInfo(login);

            return(result);
        }
Beispiel #2
0
        public TraineeProfileDTO GetInfo(string login)
        {
            Trainee trainee = db.Trainees.Get(login);

            if (trainee != null)
            {
                TraineeProfileDTO profile = new TraineeProfileDTO(trainee);

                profile.Count_Friends = trainee.FriendsSend
                                        .Where(x => x.Accepted)
                                        .Count() +
                                        trainee.FriendsRequest
                                        .Where(x => x.Accepted)
                                        .Count();

                profile.Sports = trainee.Member_in_Courses
                                 .Select(x => x.Course.Coach.Sport.Name)
                                 .Distinct()
                                 .ToList();

                profile.Count_Subscribes = trainee.Subscribes.Count();

                List <TraineeRate> trainees = db.Trainees
                                              .GetAll()
                                              .Select(x => new TraineeRate(x))
                                              .OrderByDescending(x => x.Points)
                                              .ToList();
                int place = 1;
                foreach (TraineeRate rate in trainees)
                {
                    if (profile.Rate.Points < rate.Points)
                    {
                        place++;
                    }
                    else
                    {
                        break;
                    }
                }
                profile.Rate.Place = place;

                return(profile);
            }
            return(null);
        }