Exemplo n.º 1
0
        public UserProfessions AssignProfessionToUser(int userId, ProfessionsEnum profession)
        {
            Users user = GetUserById(userId);

            if (user == null)
            {
                throw new NoEntryFoundException(userId, typeof(Users).Name);
            }

            UserProfessions existingProfession = ProfessionRepository.GetByUserIdAndProfession(user.Id, profession);

            if (existingProfession != null)
            {
                return(existingProfession);
            }

            UserProfessions userProfession = new UserProfessions
            {
                UserId       = user.Id,
                ProfessionId = (int)profession
            };

            ProfessionRepository.Add(userProfession);
            return(ProfessionRepository.GetByIdAndUserId(userProfession.Id, user.Id));
        }
Exemplo n.º 2
0
 public UserProfessions GetByUserIdAndProfession(int userId, ProfessionsEnum profession)
 {
     return(DatabaseContext
            .UserProfessions
            .AsNoTracking()
            .Where(
                x => x.UserId == userId &&
                x.ProfessionId == (int)profession
                ).Include(
                x => x.TheProfession
                ).SingleOrDefault());
 }
Exemplo n.º 3
0
        }                           //For EF

        private Professions(ProfessionsEnum @enum)
        {
            this.Id                    = (int)@enum;
            this.ProfessionName        = @enum.ToString();
            this.ProfessionDescription = @enum.GetEnumDescription();
        }
Exemplo n.º 4
0
 public List <Users> GetUsersByProfessionCriteria(ProfessionsEnum profession, string searchTerm, float currentLatitude, float currentLongitude, int pageSize, int pageNumber)
 {
     return(SearchRepository.GetPagedUserListFilteredByProfessionAndCurrentLocationAndRating(
                profession, RepairSearchTerm(searchTerm), currentLatitude, currentLongitude, pageSize, pageNumber));
 }
Exemplo n.º 5
0
        public List <Users> GetPagedUserListFilteredByProfessionAndCurrentLocationAndRating(ProfessionsEnum profession, string searchTerm, float currentLatitude, float currentLongitude, int pageSize, int pageNumber)
        {
            IQueryable <Users> firstQuery =
                DatabaseContext
                .Users
                .Where(
                    x => x.TheProfessionsThatThisUserKnows
                    .Any(
                        y => y.ProfessionId == (int)profession
                        )
                    );

            IQueryable <Users> searchTermFilteredQuery = GeneralSearchTerm(firstQuery, searchTerm);
            IQueryable <Users> locationAdjustedQuery   = DistanceQuery(searchTermFilteredQuery, currentLatitude, currentLongitude);

            return(PagingQuery(locationAdjustedQuery, pageNumber, pageSize).ToList());
        }