Exemplo n.º 1
0
        public Common.DTO.SpecialtiesAndCount GetSpecialtiesByDirectionAndDistrictAll(DirectionAndDistrictInfo directionAndDistrict)
        {
            Common.DTO.SpecialtiesAndCount specialtiesAndCount = new Common.DTO.SpecialtiesAndCount();

            var qry = from s in this.context.Specialties
                      where s.Direction.GeneralDirection.Id == directionAndDistrict.GeneralDirection
                      join u in this.context.Universities on s.University.Id equals u.Id
                      join d in this.context.Districts on u.District.Id equals d.Id
                      where d.Id == directionAndDistrict.District
                      orderby RatingProvider.GetRating(s.NumApplication, s.NumEnrolled) descending
                      select new Common.DTO.Specialty()
            {
                Name       = s.Name,
                Address    = u.Address,
                District   = d.Name,
                Site       = u.Site,
                University = u.Name,
                Subjects   = (from ss in this.context.Specialty_Subjects
                              where ss.Specialty.Id == s.Id
                              select ss.Subject.ToCommon()).ToList()
            };

            specialtiesAndCount.CountOfAllElements = qry.Count();
            specialtiesAndCount.ListSpecialties    = qry.Skip((directionAndDistrict.Page - 1) * directionAndDistrict.CountOfElementsOnPage).Take(directionAndDistrict.CountOfElementsOnPage);
            return(specialtiesAndCount);
        }
Exemplo n.º 2
0
        public IEnumerable <Common.DTO.Specialty> GetFavoriteSpecialty(string userId, int page)
        {
            var specialties = from user in this.context.User_Specialty
                              where user.User.Id == userId
                              join special in this.context.Specialties on user.Specialty.Id equals special.Id
                              join univer in this.context.Universities on special.University.Id equals univer.Id
                              join d in this.context.Districts on univer.District.Id equals d.Id
                              orderby ratingProvider.GetRating(univer.Rating, special.NumApplication, special.NumEnrolled) descending
                              select new Common.DTO.Specialty()
            {
                Id         = special.Id,
                Name       = special.Name,
                Address    = univer.Address,
                District   = d.Name,
                Site       = univer.Site,
                University = univer.Name,
                Subjects   = (from ss in this.context.Specialty_Subjects
                              where ss.Specialty.Id == special.Id
                              select ss.Subject.ToCommon()).ToList(),
                isFavorite = (from us in this.context.User_Specialty
                              where us.User.Id == userId && us.Specialty.Id == special.Id
                              select us.Id).Any()
            };

            return(specialties.Skip(page * constValues.Value.CountForPage).Take(constValues.Value.CountForPage).ToList());
        }
Exemplo n.º 3
0
        /// <summary>
        /// Returns specialties of current university and direction
        /// </summary>
        /// <param name="universityId">University Id</param>
        /// <param name="directionId">Direction Id</param>
        /// <returns>Collection of universities</returns>
        public IEnumerable <Specialty> GetSpecialtiesInUniversity(int universityId, int directionId)
        {
            IEnumerable <Specialty> need = from s in this.context.Specialties
                                           join u in this.context.Universities on s.University.Id equals u.Id
                                           where s.University.Id == universityId && s.Direction.GeneralDirection.Id == directionId
                                           orderby ratingProvider.GetRating(u.Rating, s.NumApplication, s.NumEnrolled) descending
                                           select new Specialty()
            {
                Id         = s.Id,
                Name       = s.Name,
                Address    = u.Address,
                District   = u.District.Name,
                Site       = u.Site,
                University = u.Name,
                Subjects   = (from ss in this.context.Specialty_Subjects
                              where ss.Specialty.Id == s.Id
                              select ss.Subject.ToCommon()).ToList()
            };

            return(need);
        }
Exemplo n.º 4
0
        private void GroupComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            ComboBox comboBox = sender as ComboBox;

            DisposeRatingPanel();

            Presenter.SetGroup(Groups[comboBox.SelectedIndex]);

            StudentsRating = RatingProvider.GetRating(
                Groups[comboBox.SelectedIndex].Id,
                Subjects[subjectComboBox.SelectedIndex].Id);

            DisposeRatingPanel();

            Presenter.SetStudents(StudentsRating);
        }
Exemplo n.º 5
0
 private IEnumerable <Common.DTO.Specialty> GetSpecialty(ListSubjectsAndDistrict subjects, List <int> q)
 {
     return((from s in this.context.Specialties
             join u in this.context.Universities on s.University.Id equals u.Id
             where q.Contains(s.Id)
             orderby RatingProvider.GetRating(s.NumApplication, s.NumEnrolled) descending
             select new Common.DTO.Specialty()
     {
         Name = s.Name,
         Address = u.Address,
         District = u.District.Name,
         Site = u.Site,
         University = u.Name,
         Subjects = (from ss in this.context.Specialty_Subjects
                     where ss.Specialty.Id == s.Id
                     select ss.Subject.ToCommon()).ToList()
     }).Skip((subjects.page - 1) * subjects.countOfElementsOnPage).Take(subjects.countOfElementsOnPage).ToList());
 }