Exemplo n.º 1
0
        public async Task <IActionResult> GetVacanciesByUserProfile()
        {
            var userProfile = await _crudService.Find <User>(u => u.Id == _webSession.UserId);

            var filterModel = Mapper.Map <VacancyFilterModel>(userProfile.Vacancies.FirstOrDefault());

            var filters   = VacancyConditionalFilter.GetFilters(filterModel);
            var vacancies = await _crudService.Where <Vacancy>(v => filters.All(f => f.PassFilter(v)));

            return(Ok(Mapper.Map <ICollection <VacancyModel> >(vacancies)));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> SearchVacancies([FromBody] VacancyFilterModel model)
        {
            if (_webSession.UserType == UserType.Group)
            {
                model.UserType = UserType.Musician;
            }
            else if (_webSession.UserType == UserType.Musician)
            {
                model.UserType = UserType.Group;
            }

            var filters   = VacancyConditionalFilter.GetFilters(model);
            var vacancies = await _crudService.Where <Vacancy>(v => !v.IsClosed && v.User.Type == model.UserType);

            var foundVacancies = vacancies.ToList().Where(v => filters.All(f => f.PassFilter(v))).ToList();

            return(Ok(Mapper.Map <List <VacancyModel> >(foundVacancies)));
        }