public IQueryable <Company> Search(IQueryable <Company> query, CompanyFilters filters)
 {
     if (!string.IsNullOrWhiteSpace(filters.Name))
     {
         query = query.Where(o => o.Name.Contains(filters.Name));
     }
     return(query);
 }
Example #2
0
        /// <inheritdoc />
        public async Task <List <CompanyModel> > GetCompanies(string token, CompanyFilters filters = null)
        {
            var queryFilter    = filters == null ? "" : PrepareCompanyQueryFilters(filters);
            var uri            = new Uri($"{_publicApiUrl}/company?{queryFilter}");
            var responseString = await SendGetRequest(uri, token);

            return(GetPublicApiResponse <List <CompanyModel> >(responseString));
        }
Example #3
0
 public List <CompanyDto> Get([FromUri] CompanyFilters filters)
 {
     if (filters == null)
     {
         return(Get());
     }
     return(CompanyDtoManager.CompanyDtoListByFilters(filters));
 }
Example #4
0
        private string PrepareCompanyQueryFilters(CompanyFilters filters)
        {
            string query = "";

            if (!string.IsNullOrEmpty(filters.Name))
            {
                query += "companyNameFilter=" + filters.Name + "&";
            }
            return(query);
        }
        public CompanyFilters GetFilters()
        {
            var filters = new CompanyFilters()
            {
                Page  = Convert.ToInt32(HttpContext.Request.Query["page"]),
                Limit = Convert.ToInt32(HttpContext.Request.Query["limit"]),
                Name  = HttpContext.Request.Query["name"],
            };

            return(filters);
        }
        public async Task <ResponseModel <CompanyViewModel> > GetList(CompanyFilters filters, SortCol sortCol, AccountViewModel current)
        {
            var query = _context.Company.Where(o => o.Id != 0);

            query = Search(query, filters);
            query = Sort(query, sortCol);
            var vms = await query.Skip((filters.Page - 1) *filters.Limit).Take(filters.Limit)
                      .ProjectTo <CompanyViewModel>().ToListAsync();

            ResponseModel <CompanyViewModel> result = new ResponseModel <CompanyViewModel>();

            result.status  = 0;
            result.message = "";
            result.total   = query.Count();
            result.data    = vms;
            return(result);
        }
Example #7
0
        public static List <CompanyDto> CompanyListByFilters(CompanyFilters filters)
        {
            List <CompanyDto> companyDtos;
            List <Company>    companies;

            using (placementDepartmentDBEntities placementDepartmentDB = new placementDepartmentDBEntities())
            {
                companies = placementDepartmentDB.Company
                            .Where(cmp =>
                                   (filters.mainSubject == 0 && filters.subjectByJobs == 0) ||
                                   (filters.mainSubject != 0 && cmp.mainField == filters.mainSubject) ||
                                   (filters.subjectByJobs != 0 &&
                                    cmp.Contact.
                                    Where(cnt => cnt.Job.
                                          Where(j => j.subjectId == filters.subjectByJobs).ToList().Count > 0)
                                    .ToList().Count > 0
                                   ))
                            .ToList();
                companyDtos = AutoMapperConfiguration.mapper.Map <List <CompanyDto> >(companies);
                return(companyDtos);
            }
        }
 public static List <CompanyDto> CompanyDtoListByFilters(CompanyFilters filters)
 {
     return(placementDepartmentDAL.CompanyManager.CompanyListByFilters(filters));
 }