Beispiel #1
0
        public IEnumerable <EnterpriseViewModel> GetEnterprisesByNameAndType(string name, int enterpriseTypeId)
        {
            Expression <Func <Enterprise, bool> > predicate = ExpressionExtension.Query <Enterprise>();

            predicate = predicate.And(it => it.EnterpriseType.Id == enterpriseTypeId);

            if (!string.IsNullOrWhiteSpace(name))
            {
                predicate = predicate.And(it => it.Name.ToLower().Contains(name.ToLower()));
            }

            var data = _enterpriseService.Find(predicate, it => it.EnterpriseType);

            return(Mapper.Map <IEnumerable <EnterpriseViewModel> >(data));
        }