private PredicateGroup GetPredicates(string userId)
        {
            var predicateGroup = new PredicateGroup { Operator = GroupOperator.And, Predicates = new List<IPredicate>() };
            predicateGroup.Predicates.Add(Predicates.Field<CheckIns>(c => c.CheckInDate, Operator.Ge, DateTime.Today));
            predicateGroup.Predicates.Add(Predicates.Field<CheckIns>(c => c.UserID, Operator.Like, userId));

            return predicateGroup;
        }
 public Model.Entities.ForumActiveDirectoryMapping GetDepartmentForumMappings(string forumName)
 {
     var predicateGroup = new PredicateGroup { Operator = GroupOperator.And, Predicates = new List<IPredicate>() };
     predicateGroup.Predicates.Add(Predicates.Field<Model.Entities.ForumActiveDirectoryMapping>(f => f.ForumName, Operator.Eq, forumName));
     predicateGroup.Predicates.Add(Predicates.Field<Model.Entities.ForumActiveDirectoryMapping>(f => f.IsDeleted, Operator.Eq, false));
     predicateGroup.Predicates.Add(Predicates.Field<Model.Entities.ForumActiveDirectoryMapping>(f => f.IsActive, Operator.Eq, true));
     return SqlHelper.Find<Model.Entities.ForumActiveDirectoryMapping>(predicateGroup);
 }
        public static User GetUserByNameAndPassword(this IDatabase db, string name, string password)
        {
            var byUserNameAndPassword = new PredicateGroup { Operator = GroupOperator.And, Predicates = new List<IPredicate>() };
            byUserNameAndPassword.Predicates.Add(Predicates.Field<User>(u => u.UserName, Operator.Eq, name));
            byUserNameAndPassword.Predicates.Add(Predicates.Field<User>(u => u.Password, Operator.Eq, password));

            return db.Connection.GetList<User>(byUserNameAndPassword).ToList().FirstOrDefault();
        }
 public Int32 GetProcessorStatus(ApplicationKey applicationKey)
 {
     var predicateGroup = new PredicateGroup { Operator = GroupOperator.And, Predicates = new List<IPredicate>() };
     predicateGroup.Predicates.Add(Predicates.Field<ApplicationKey>(f => f.IsDeleted, Operator.Eq, false));
     predicateGroup.Predicates.Add(Predicates.Field<ApplicationKey>(f => f.AppId, Operator.Eq, applicationKey.AppId));
     var output = SqlHelper.Find<ApplicationKey>(predicateGroup);
     return output.StatusId;
 }
Exemple #5
0
        public static IEnumerable<Character> GetCharactersForAccount(Account account)
        {
            var data = DataConnection.Resolve();
            var group = new PredicateGroup() {Operator = GroupOperator.And, Predicates = new List<IPredicate>()};
            group.Predicates.Add(Predicates.Field<Character>(a => a.AccountId, Operator.Eq, account.Id));
            group.Predicates.Add(Predicates.Field<Character>(a => a.Deleted, Operator.Eq, false));

            return data.Repo.GetList<Character>(group, buffered: false);
        }
Exemple #6
0
        public Account TryLogin(string user, string pass)
        {
            var data = DataConnection.Resolve();
            var group = new PredicateGroup { Operator = GroupOperator.And, Predicates = new List<IPredicate>() };
            group.Predicates.Add(Predicates.Field<Account>(a => a.Username, Operator.Eq, user));
            group.Predicates.Add(Predicates.Field<Account>(a => a.Password, Operator.Eq, pass));

            return data.Repo.Get<Account>(group);
        }
 public Subscription GetSubscriptions(Subscription subscription)
 {
     var predicateGroup = new PredicateGroup { Operator = GroupOperator.And, Predicates = new List<IPredicate>() };
     predicateGroup.Predicates.Add(Predicates.Field<Subscription>(f => f.IsActive, Operator.Eq, true));
     predicateGroup.Predicates.Add(Predicates.Field<Subscription>(f => f.IsDeleted, Operator.Eq, false));
     predicateGroup.Predicates.Add(Predicates.Field<Subscription>(f => f.EmployeeName, Operator.Eq, subscription.EmployeeName));
     predicateGroup.Predicates.Add(Predicates.Field<Subscription>(f => f.ForumName, Operator.Eq, subscription.ForumName));
     return
         SqlHelper.Find<Subscription>(predicateGroup);
 }
Exemple #8
0
        public Customer GetCustomerByNumber(string number)
        {
            using (var connectionScope = new ConnectionScope())
            {
                var where = new PredicateGroup { Operator = GroupOperator.And, Predicates = new List<IPredicate>() };
                where.Predicates.Add(Predicates.Field<Customer>(f => f.Number, Operator.Eq, number));

                return connectionScope.Connection.GetList<Customer>(where.Predicates.Any() ? where : null).FirstOrDefault();
            }
        }
 public bool DeleteUserModule(Model.Entities.UserModule userModule)
 {
     var result = GetUserModule(userModule);
     if (null==result)
     {
         return false;
     }
     var predicateGroup = new PredicateGroup { Operator = GroupOperator.And, Predicates = new List<IPredicate>() };
     predicateGroup.Predicates.Add(Predicates.Field<Model.Entities.UserModule>(f => f.LdapName, Operator.Eq, result.LdapName));
     return SqlHelper.Delete<Model.Entities.UserModule>(predicateGroup);
 }
        public StaticContents GetStaticContents(StaticContents staticContents)
        {
            staticContents.StartDate = Convert.ToDateTime("2015-02-17 00:00:00.000");
            staticContents.EndDate = Convert.ToDateTime("2015-03-30 00:00:00.000");

            var predicateGroup = new PredicateGroup { Operator = GroupOperator.And, Predicates = new List<IPredicate>() };
            predicateGroup.Predicates.Add(Predicates.Field<StaticContents>(f => f.Guid, Operator.Eq, staticContents.Guid));
            predicateGroup.Predicates.Add(Predicates.Field<StaticContents>(f => f.IsActive, Operator.Eq, true));
            //predicateGroup.Predicates.Add(Predicates.Field<StaticContents>(f => f.EndDate, Operator.Lt, DateTime.Now.AddDays(1)));
            return SqlHelper.Find<StaticContents>(predicateGroup);
        }
 public IList<Model.Entities.UserModule> GetAllUserModuleByLdapUser(Model.Entities.UserModule userModule)
 {
     IEnumerable<UserModule> result = new List<UserModule>();
     using (SqlConnection cn = new SqlConnection(ApplicationConfiguration.ConnectionString))
     {
         cn.Open();
         var predicateGroup = new PredicateGroup { Operator = GroupOperator.And, Predicates = new List<IPredicate>() };
         predicateGroup.Predicates.Add(Predicates.Field<UserModule>(f => f.LdapName, Operator.Eq, userModule.LdapName));
         result = cn.GetList<UserModule>(predicateGroup);
         cn.Close();
     }
     return result.ToList();
 }
Exemple #12
0
		/// <summary>
		/// Returns a list of bill transactions scheduled for this bill during this timeframe
		/// </summary>
		/// <param name="billId">Get all bill transactions for a value of null</param>
		/// <param name="from"></param>
		/// <param name="to"></param>
		/// <returns></returns>
		public ServiceResult<IEnumerable<BillTransaction>> GetBillTransactions(int? billId, DateTime? from = null, DateTime? to = null)
		{
			var result = new ServiceResult<IEnumerable<BillTransaction>>();

			var predicates = new List<IPredicate>();

			if (billId.HasValue)
				predicates.Add(Predicates.Field<BillTransaction>(x => x.BillId, Operator.Eq, billId.Value));
			if (from.HasValue)
				predicates.Add(Predicates.Field<BillTransaction>(x => x.Timestamp, Operator.Ge, from.Value));
			if (to.HasValue)
				predicates.Add(Predicates.Field<BillTransaction>(x => x.Timestamp, Operator.Le, to.Value));

			var predicate = new PredicateGroup { Operator = GroupOperator.And, Predicates = predicates };
			var billTransactions = _db.GetList<BillTransaction>(predicate);

			result.Result = billTransactions;
			return result;
		}
Exemple #13
0
        public Resposta <FotoDetalhe> ObterDetalheImagem(int orc, int numeroFoto, string connectionString)
        {
            try
            {
                //Altera o contexto de acordo com a requisição.
                dapperContext.connection.ConnectionString = connectionString;
                Expression <Func <Foto, object> > predicateOrc  = c => c.Orc;
                Expression <Func <Foto, object> > predicateFoto = c => c.Numfot;

                var pgMain = new PredicateGroup {
                    Operator = GroupOperator.And, Predicates = new List <IPredicate>()
                };
                pgMain.Predicates.Add(Predicates.Field <Foto>(predicateOrc, Operator.Eq, orc));
                pgMain.Predicates.Add(Predicates.Field <Foto>(predicateFoto, Operator.Eq, numeroFoto));

                var voFoto = this.dapperContext.connection.GetList <Foto>(pgMain).FirstOrDefault();

                var arquivoResponse = ObterArquivoImagem(voFoto, connectionString);

                if (arquivoResponse.Status == 0)
                {
                    var arquivo = arquivoResponse.Data.FirstOrDefault();

                    var fotoDetalhe = new FotoDetalhe
                    {
                        Foto  = arquivo.foto,
                        Thumb = arquivo.thumb
                    };

                    return(this.responseDetalhe.SetData(fotoDetalhe, (int)eRespostaStatus.OK));
                }
                else
                {
                    return(this.responseDetalhe.SetMessage("Imagem não encontrada", (int)eRespostaStatus.OK));
                }
            }
            catch (Exception ex)
            {
                return(this.responseDetalhe.SetMessage("Erro ao Obter Detalhe Imagem", (int)eRespostaStatus.Erro, ex));
            }
        }
        /// <summary>
        /// 编辑
        /// </summary>
        /// <param name="category"></param>
        /// <returns></returns>
        public MsgEntity Edit(T_EC_KeyWords keyword)
        {
            MsgEntity me = new MsgEntity();

            if (keyword == null || string.IsNullOrEmpty(keyword.KEY_WORD))
            {
                me.MsgCode = MsgEntity.MsgCodeEnum.Failure;
                me.MsgDes  = "名称不能为空";
                return(me);
            }
            //查找关键字是否有相同值(不同id的dict_code不能相同)
            PredicateGroup pg = new PredicateGroup {
                Operator = GroupOperator.And, Predicates = new List <IPredicate>()
            };

            pg.Predicates.Add(Predicates.Field <T_EC_KeyWords>(f => f.KEY_WORD, Operator.Eq, keyword.KEY_WORD));
            pg.Predicates.Add(Predicates.Field <T_EC_KeyWords>(f => f.PLAT_TYPE, Operator.Eq, keyword.PLAT_TYPE));
            pg.Predicates.Add(Predicates.Field <T_EC_KeyWords>(f => f.ID, Operator.Eq, keyword.ID, true));
            int count = dao.Count <T_EC_KeyWords>(pg);

            if (count > 0)
            {
                me.MsgCode = MsgEntity.MsgCodeEnum.Failure;
                me.MsgDes  = "同一平台名称重复";
                return(me);
            }
            bool result = false;

            try
            {
                result     = dao.Update <T_EC_KeyWords>(keyword);
                me.MsgCode = MsgEntity.MsgCodeEnum.Success;
                me.MsgDes  = "编辑成功";
            }
            catch (Exception ex)
            {
                me.MsgCode = MsgEntity.MsgCodeEnum.Failure;
                me.MsgDes  = ex.Message;
            }
            return(me);
        }
 public User FindUser(string email, string password)
 {
     using (var connection = new NpgsqlConnection(settings.ConnectionString))
     {
         if (password == null)
         {
             var predicate = Predicates.Field <User>(u => u.Email, Operator.Eq, email);
             var users     = connection.GetList <User>(predicate).ToList();
             return(users.Count == 0 ? null : users.First());
         }
         else
         {
             var pg = new PredicateGroup {
                 Operator = GroupOperator.And, Predicates = new List <IPredicate>()
             };
             pg.Predicates.Add(Predicates.Field <User>(u => u.Email, Operator.Eq, email));
             pg.Predicates.Add(Predicates.Field <User>(u => u.Password, Operator.Eq, password));
             return(connection.GetList <User>(pg).First());
         }
     }
 }
Exemple #16
0
        public static Character GetCharacter(Account account = null, Guid id = default(Guid), string name = null)
        {
            var data = DataConnection.Resolve().Repo;
            var group = new PredicateGroup() { Operator = GroupOperator.And, Predicates = new List<IPredicate>() };

            if (account != null)
                group.Predicates.Add(Predicates.Field<Character>(a => a.AccountId, Operator.Eq, account.Id));

            if (name != null)
                group.Predicates.Add(Predicates.Field<Character>(a => a.Name, Operator.Eq, name));

            if (id != default(Guid))
                group.Predicates.Add(Predicates.Field<Character>(a => a.Id, Operator.Eq, id));

            if (group.Predicates.Count == 0)
                throw new Exception("No predicates created");

            group.Predicates.Add(Predicates.Field<Character>(a => a.Deleted, Operator.Eq, false));

            return data.Get<Character>(group);
        }
Exemple #17
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public ActionResult GetPageList()
        {
            using (SqlConnection cn = new SqlConnection(DapperHelper.ConnStr))
            {
                var pg = new PredicateGroup {
                    Operator = GroupOperator.And, Predicates = new List <IPredicate>()
                };
                pg.Predicates.Add(Predicates.Field <Table1>(f => f.Id, Operator.Ge, 10));
                pg.Predicates.Add(Predicates.Field <Table1>(f => f.name, Operator.Like, "jack1%"));

                IList <ISort> sort = new List <ISort>()
                {
                    (new Sort()
                    {
                        PropertyName = "id"
                    })
                };
                var r = cn.GetPage <Table1>(pg, sort, 1, 20);
                return(Content(JsonConvert.SerializeObject(r)));
            }
        }
Exemple #18
0
        /// <summary>
        /// 分页获取
        /// </summary>
        public static string GetPageBy()
        {
            var sw = new Stopwatch();

            sw.Start();
            IList <ISort> sort = new List <ISort>
            {
                Predicates.Sort <Person>(p => p.CrteatDate)
            };
            int totalCount = 0;
            var pga        = new PredicateGroup()
            {
                Operator = GroupOperator.And, Predicates = new List <IPredicate>()
            };

            pga.Predicates.Add(Predicates.Field <Person>(f => f.CrteatDate, Operator.Ge, DateTime.Now.AddDays(-1)));
            IList <Person> result = PersonRepository.Value.GetPage(2, 10, out totalCount, pga, sort);

            sw.Stop();
            return(string.Format("共获取{0}条记录,共{2}条记录,耗时:{1}毫秒", result.Count, sw.ElapsedMilliseconds, totalCount));
        }
Exemple #19
0
        public BuyerShoppingCart GetModel(int buyerId, int sellerId, int productId, string connectionString, out string errMsg)
        {
            BuyerShoppingCart model = null;

            errMsg = string.Empty;
            try
            {
                PredicateGroup pdg = new PredicateGroup();
                pdg.Predicates = new List <IPredicate>();
                pdg.Predicates.Add(Predicates.Field <BuyerShoppingCart>(o => o.BuyerId, Operator.Eq, buyerId));
                pdg.Predicates.Add(Predicates.Field <BuyerShoppingCart>(o => o.ProductId, Operator.Eq, productId));
                pdg.Predicates.Add(Predicates.Field <BuyerShoppingCart>(o => o.SellerId, Operator.Eq, sellerId));

                model = GetModel(pdg, connectionString, out errMsg);
            }
            catch (Exception ex)
            {
                Logger.LogError4Exception(ex, "AppLogger");
            }
            return(model);
        }
        public async Task <ActionResult <IEnumerable <string> > > GetFromDbByFilterField([FromQuery] Domain.NewsArticle newsArticle)
        {
            var predicateGroup = new PredicateGroup()
            {
                Operator   = GroupOperator.Or,
                Predicates = new List <IPredicate>()
            };

            if (!string.IsNullOrEmpty(newsArticle.PUBLISHER))
            {
                predicateGroup.Predicates.Add(Predicates.Field <Domain.NewsArticle>(f => f.PUBLISHER, Operator.Like, newsArticle.PUBLISHER));
            }
            if (!string.IsNullOrEmpty(newsArticle.CATEGORY))
            {
                predicateGroup.Predicates.Add(Predicates.Field <Domain.NewsArticle>(f => f.CATEGORY, Operator.Like, newsArticle.CATEGORY));
            }

            var filteredArticles = await newsRepo.GetByPredicateAsync(predicateGroup);

            return(Ok(filteredArticles));
        }
        /// <summary>
        /// 编辑
        /// </summary>
        /// <param name="category"></param>
        /// <returns></returns>
        public MsgEntity Edit(T_EC_KWCategory category)
        {
            MsgEntity me = new MsgEntity();

            if (category == null || string.IsNullOrEmpty(category.CATEGORY_CODE) || string.IsNullOrEmpty(category.CATEGORY_NAME))
            {
                me.MsgCode = MsgEntity.MsgCodeEnum.Failure;
                me.MsgDes  = "编码或名称不能为空";
                return(me);
            }
            //查找关键字是否有相同值(不同id的dict_code不能相同)
            PredicateGroup pg = new PredicateGroup {
                Operator = GroupOperator.And, Predicates = new List <IPredicate>()
            };

            pg.Predicates.Add(Predicates.Field <T_EC_KWCategory>(f => f.CATEGORY_CODE, Operator.Eq, category.CATEGORY_CODE));
            pg.Predicates.Add(Predicates.Field <T_EC_KWCategory>(f => f.ID, Operator.Eq, category.ID, true));
            int count = dao.Count <T_EC_KWCategory>(pg);

            if (count > 0)
            {
                me.MsgCode = MsgEntity.MsgCodeEnum.Failure;
                me.MsgDes  = "编码重复";
                return(me);
            }
            bool result = false;

            try
            {
                result     = dao.Update <T_EC_KWCategory>(category);
                me.MsgCode = MsgEntity.MsgCodeEnum.Success;
                me.MsgDes  = "编辑成功";
            }
            catch (Exception ex)
            {
                me.MsgCode = MsgEntity.MsgCodeEnum.Failure;
                me.MsgDes  = ex.Message;
            }
            return(me);
        }
Exemple #22
0
        /// <summary>
        /// 修改字典
        /// </summary>
        /// <param name="dict"></param>
        /// <returns></returns>
        public MsgEntity EditDictItem(T_Sys_DictItem dictItem)
        {
            MsgEntity me = new MsgEntity();

            if (dictItem == null || string.IsNullOrEmpty(dictItem.DI_CODE))
            {
                me.MsgCode = MsgEntity.MsgCodeEnum.Failure;
                me.MsgDes  = "字典项编码不能为空";
                return(me);
            }
            //查找关键字是否有相同值(不同id的dict_code不能相同)
            PredicateGroup pg = new PredicateGroup {
                Operator = GroupOperator.And, Predicates = new List <IPredicate>()
            };

            pg.Predicates.Add(Predicates.Field <T_Sys_DictItem>(f => f.DI_CODE, Operator.Eq, dictItem.DI_CODE));
            pg.Predicates.Add(Predicates.Field <T_Sys_DictItem>(f => f.ID, Operator.Eq, dictItem.ID, true));
            int count = dao.Count <T_Sys_DictItem>(pg);

            if (count > 0)
            {
                me.MsgCode = MsgEntity.MsgCodeEnum.Failure;
                me.MsgDes  = "字典项编码重复";
                return(me);
            }
            bool result = false;

            try
            {
                result     = dao.Update <T_Sys_DictItem>(dictItem);
                me.MsgCode = MsgEntity.MsgCodeEnum.Success;
                me.MsgDes  = "字典项编辑成功";
            }
            catch (Exception ex)
            {
                me.MsgCode = MsgEntity.MsgCodeEnum.Failure;
                me.MsgDes  = ex.Message;
            }
            return(me);
        }
Exemple #23
0
        public OptResult DeleteBatch(IEnumerable <string> ids)
        {
            OptResult rst = null;
            //1、用户是否存在
            var predicate = Predicates.Field <User>(u => u.user_id, Operator.Eq, ids);
            var count     = _usrRep.Count(predicate);

            if (count < ids.Count())
            {
                rst = OptResult.Build(ResultCode.DataNotFound, Msg_BatchDeleteUser);
                return(rst);
            }
            //2、超级管理员不能被删除(这里只根据用户名判断,后续可以扩展根据角色或其他规则)
            PredicateGroup pg = new PredicateGroup {
                Operator = GroupOperator.And, Predicates = new List <IPredicate> {
                    predicate
                }
            };

            pg.Predicates.Add(Predicates.Field <User>(u => u.user_name, Operator.Eq, "admin"));
            count = _usrRep.Count(pg);
            if (count > 0)
            {
                rst = OptResult.Build(ResultCode.IllegalOpt, Msg_BatchDeleteUser + ",管理员不允许删除");
                return(rst);
            }

            try
            {
                //TODO,应该起事务,删除用户权限
                bool val = _usrRep.Delete(predicate);
                rst = OptResult.Build(val ? ResultCode.Success : ResultCode.Fail, Msg_BatchDeleteUser);
            }
            catch (Exception ex)
            {
                LogHelper.LogError(Msg_BatchDeleteUser, ex);
                rst = OptResult.Build(ResultCode.DbError, Msg_BatchDeleteUser);
            }
            return(rst);
        }
        public PageResult <T> GetPager(PredicateGroup pg, PageQuery pageQuery)
        {
            var result = new PageResult <T>();

            ////PageIndex等于0时返回全部
            if (pageQuery.PageIndex == 0)
            {
                using (var conn = ConnectionFactory.CreateConnection())
                {
                    result.Row   = conn.GetList <T>(pg, SortExtension.ToSortList <T>(pageQuery.OrderList)).ToList();
                    result.Total = result.Row.Count;
                    return(result);
                }
            }

            if (pageQuery.PageIndex < 0)
            {
                throw new ArgumentException(nameof(pageQuery.PageIndex));
            }

            if (pageQuery.PageSize <= 0)
            {
                throw new ArgumentException(nameof(pageQuery.PageSize));
            }

            using (var conn = ConnectionFactory.CreateConnection())
            {
                var total = conn.Count <T>(pg);
                result.Total = total;

                //判断请求有数据时再查询
                if (total > (pageQuery.PageIndex - 1) * pageQuery.PageSize)
                {
                    result.Row = conn.GetPage <T>(pg, SortExtension.ToSortList <T>(pageQuery.OrderList), pageQuery.PageIndex - 1, pageQuery.PageSize)
                                 .ToList();
                }

                return(result);
            }
        }
        public void EditarAdd(MenuAdminFormViewModel model)
        {
            var entity = _servicoMenu.ObterPorId(model.Id);

            if (entity != null)
            {
                entity.menuPai          = model.MenuPaiId;
                entity.icone            = model.Icone;
                entity.nome             = model.Nome;
                entity.ordem            = model.Ordem;
                entity.tipo             = model.Tipo;
                entity.funcionalidadeID = model.FuncionalidadeId;
                entity.tipoAbertura     = model.TipoAbertura;
                _servicoMenu.Atualizar(entity);

                var where = new PredicateGroup {
                    Operator = GroupOperator.And, Predicates = new List <IPredicate>()
                };
                @where.Predicates.Add(Predicates.Field <AspNetRolesMenu>(f => f.MenusId, Operator.Eq, entity.id));
                var aspNetRoles = _servicoAspNetMenu.ObterPor(where);

                if (aspNetRoles.Any())
                {
                    foreach (var x in aspNetRoles)
                    {
                        _servicoAspNetMenu.Deletar(x);
                    }
                }

                foreach (var x in model.PerfisVinculados)
                {
                    var aspnetMenu = new AspNetRolesMenu
                    {
                        AspNetRolesId = x,
                        MenusId       = entity.id
                    };
                    _servicoAspNetMenu.Adicionar(aspnetMenu);
                }
            }
        }
        public IEnumerable <Fila> ObterPor(bool?aceitaLigacao, bool?aceitaEmail, bool?aceitaTarefa,
                                           bool?aceitaChatSms, bool?aceitaChatWeb, int?departamentoId)
        {
            var where = new PredicateGroup {
                Operator = GroupOperator.And, Predicates = new List <IPredicate>()
            };
            where.Predicates.Add(Predicates.Field <Fila>(f => f.Ativo, Operator.Eq, true));

            if (aceitaLigacao.HasValue)
            {
                where.Predicates.Add(Predicates.Field <Fila>(f => f.AceitaLigacoes, Operator.Eq, aceitaLigacao));
            }

            if (aceitaEmail.HasValue)
            {
                where.Predicates.Add(Predicates.Field <Fila>(f => f.AceitaEmails, Operator.Eq, aceitaEmail));
            }

            if (aceitaTarefa.HasValue)
            {
                where.Predicates.Add(Predicates.Field <Fila>(f => f.AceitaTarefas, Operator.Eq, aceitaTarefa));
            }

            if (aceitaChatSms.HasValue)
            {
                where.Predicates.Add(Predicates.Field <Fila>(f => f.AceitaChatSms, Operator.Eq, aceitaChatSms));
            }

            if (aceitaChatWeb.HasValue)
            {
                where.Predicates.Add(Predicates.Field <Fila>(f => f.AceitaChatWeb, Operator.Eq, aceitaChatWeb));
            }

            if (departamentoId.HasValue)
            {
                where.Predicates.Add(Predicates.Field <Fila>(f => f.DepartamentoId, Operator.Eq, departamentoId));
            }

            return(ObterPor(where));
        }
Exemple #27
0
        public List <ProductInfo> GetList(int sellerId, int productClassId, string connectionString, out string errMsg)
        {
            List <ProductInfo> list = new List <ProductInfo>();

            errMsg = string.Empty;
            try
            {
                PredicateGroup pdg = new PredicateGroup();
                pdg.Predicates = new List <IPredicate>();
                pdg.Predicates.Add(Predicates.Field <ProductInfo>(o => o.SellerId, Operator.Eq, sellerId));
                if (productClassId > 0)
                {
                    pdg.Predicates.Add(Predicates.Field <ProductInfo>(o => o.ClassId, Operator.Eq, productClassId));
                }
                list = GetList(pdg, connectionString, out errMsg);
            }
            catch (Exception ex)
            {
                Logger.LogError4Exception(ex, "AppLogger");
            }
            return(list);
        }
Exemple #28
0
        /// <summary>
        /// 分页查询
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public PagedDto GetStudentsPagination(StudentPagedModel model)
        {
            var predicateGroup = new PredicateGroup {
                Operator = GroupOperator.And, Predicates = new List <IPredicate>()
            };

            if (!string.IsNullOrEmpty(model.Sex))
            {
                var predicate1 = Predicates.Field <Student>(n => n.Ssex, Operator.Eq, model.Sex);
                predicateGroup.Predicates.Add(predicate1);
            }
            if (!string.IsNullOrEmpty(model.Name))
            {
                var predicate2 = Predicates.Field <Student>(n => n.Sname, Operator.Like, model.Name);
                predicateGroup.Predicates.Add(predicate2);
            }

            IList <ISort> sort = new List <ISort>
            {
                new Sort()
                {
                    PropertyName = "sid", Ascending = true
                },
                new Sort()
                {
                    PropertyName = "sage", Ascending = false
                }
            };

            long totalCount = 0L;
            var  students   = DataRepository.GetPage <Student>(model.PageIndex, model.PageSize, out totalCount, predicateGroup, sort);
            var  dataList   = AutoMapperHelper <IEnumerable <Student>, IEnumerable <StudentDto> > .AutoConvert(students);

            return(new PagedDto()
            {
                Count = totalCount,
                Data = dataList
            });
        }
Exemple #29
0
        public IEnumerable <AtividadeParteEnvolvida> BuscarPor(long atividadeId, long?pessoaFisicaId,
                                                               long?pessoaJuridicaId)
        {
            var where = new PredicateGroup {
                Operator = GroupOperator.And, Predicates = new List <IPredicate>()
            };
            where.Predicates.Add(Predicates.Field <AtividadeParteEnvolvida>(f => f.AtividadesId, Operator.Eq, atividadeId));

            if (pessoaFisicaId.HasValue)
            {
                where.Predicates.Add(Predicates.Field <AtividadeParteEnvolvida>(f => f.PessoasFisicasId, Operator.Eq,
                                                                                pessoaFisicaId));
            }

            if (pessoaJuridicaId.HasValue)
            {
                where.Predicates.Add(Predicates.Field <AtividadeParteEnvolvida>(f => f.PessoasJuridicasId, Operator.Eq,
                                                                                pessoaJuridicaId));
            }

            return(ObterPor(where));
        }
Exemple #30
0
        public async Task RemoveAsync(string key)
        {
            var parameters        = new Dictionary <string, object>();
            var dynamicParameters = new DynamicParameters();

            var pg = new PredicateGroup {
                Operator = GroupOperator.And, Predicates = new List <IPredicate>()
            };

            pg.Predicates.Add(Predicates.Field <Entities.Token>(t => t.Key, Operator.Eq, key));
            pg.Predicates.Add(Predicates.Field <Entities.Token>(t => t.TokenType, Operator.Eq, tokenType));

            var sql = options.SqlGenerator.Delete(new TokenMapper(options), pg, parameters);

            dynamicParameters = new DynamicParameters();
            foreach (var parameter in parameters)
            {
                dynamicParameters.Add(parameter.Key, parameter.Value);
            }

            await options.Connection.ExecuteAsync(sql, dynamicParameters);
        }
        public List <V_BG_Email_Reciever> GetList(string userName)
        {
            try
            {
                PredicateGroup pmain = new PredicateGroup {
                    Operator = GroupOperator.And, Predicates = new List <IPredicate>()
                };
                pmain.Predicates.Add(Predicates.Field <V_BG_Email_Reciever>(f => f.RevieverUserId, Operator.Eq, userName));
                pmain.Predicates.Add(Predicates.Field <V_BG_Email_Reciever>(f => f.RevieverIsDel, Operator.Eq, 0));

                IList <ISort> sort = new List <ISort> {
                    Predicates.Sort <V_BG_Email_Reciever>(o => o.AddTime, false)
                };

                var list = _bgVEmailRecieverRepository.QueryList(pmain, sort);
                return(list.ToList());
            }
            catch (Exception)
            {
                return(null);
            }
        }
Exemple #32
0
        public async Task RevokeAsync(string subject, string client)
        {
            var parameters        = new Dictionary <string, object>();
            var dynamicParameters = new DynamicParameters();

            var pg = new PredicateGroup {
                Operator = GroupOperator.And, Predicates = new List <IPredicate>()
            };

            pg.Predicates.Add(Predicates.Field <Consent>(t => t.Subject, Operator.Eq, subject));
            pg.Predicates.Add(Predicates.Field <Consent>(t => t.ClientId, Operator.Eq, client));

            var sql = options.SqlGenerator.Delete(new ConsentMapper(options), pg, parameters);

            dynamicParameters = new DynamicParameters();
            foreach (var parameter in parameters)
            {
                dynamicParameters.Add(parameter.Key, parameter.Value);
            }

            await options.Connection.ExecuteAsync(sql, dynamicParameters);
        }
Exemple #33
0
        private static string GetList()
        {
            Stopwatch sw = new Stopwatch();

            sw.Start();
            IPredicateGroup group = new PredicateGroup()
            {
                Operator = GroupOperator.Or, Predicates = new List <IPredicate>()
            };
            IBetweenPredicate bet = Predicates.Between <Person>(f => f.Sex, new BetweenValues {
                Value1 = 0, Value2 = 2
            });

            group.Predicates.Add(bet);
            IPredicate pre = Predicates.Field <Person>(f => f.FirstName, Operator.Like, "First");

            group.Predicates.Add(pre);
            IList <Person> result = PersonRepository.Value.GetList(group);

            sw.Stop();
            return(string.Format("共获取{0}条记录,耗时:{1}毫秒", result.Count, sw.ElapsedMilliseconds));
        }
        public void SearchTextDocumentTest()
        {
            var predicate = new PredicateGroup <LuceneCache.TextDocument>();

            predicate.Add(f => f.SearchText.StartsWith("keyword"));

            var data = new[] {
                new LuceneCache.TextDocument("", "", "", new ExtractionPointDetail())
                {
                    SearchText = "keyword"
                },

                new LuceneCache.TextDocument("", "", "", new ExtractionPointDetail())
                {
                    SearchText = "non-keyword"
                }
            };

            var result = data.AsQueryable().Where(predicate.Combine(Expression.OrElse)).ToArray();

            Assert.AreEqual(1, result.Length);
        }
        public List <T_BG_Email> List(long userId)
        {
            try
            {
                PredicateGroup pmain = new PredicateGroup {
                    Operator = GroupOperator.And, Predicates = new List <IPredicate>()
                };
                pmain.Predicates.Add(Predicates.Field <T_BG_Email>(f => f.SendUserId, Operator.Eq, userId));
                pmain.Predicates.Add(Predicates.Field <T_BG_Email>(f => f.IsDel, Operator.Eq, 0));

                IList <ISort> sort = new List <ISort> {
                    Predicates.Sort <T_BG_Email>(o => o.AddTime, false)
                };

                var list = _bgEmailRepository.QueryList(pmain, sort);
                return(list.ToList());
            }
            catch (Exception)
            {
                return(null);
            }
        }
            public static PredicateGroup Convert(Expression expression)
            {
                if (expression.NodeType == ExpressionType.Lambda)
                {
                    expression = ((LambdaExpression)expression).Body;
                }

                var converter = new PredicateConverter();
                var result    = converter.Parse(expression);

                if (!(result is PredicateGroup group))
                {
                    group = new PredicateGroup {
                        Predicates = new List <IPredicate> {
                            result
                        }
                    }
                }
                ;

                return(group);
            }
Exemple #37
0
        public JxcFlowCellItem Get(ushort eId, string cellNumber)
        {
            var flowCell = new JxcFlowCellItem();

            var pg = new PredicateGroup {
                Operator = GroupOperator.Or, Predicates = new List <IPredicate>()
            };

            pg.Predicates.Add(Predicates.Field <JxcFlowCellItem>(f => f.cell_number, Operator.Eq, cellNumber));
            IList <ISort> sorts = new List <ISort>();
            ISort         sort  = new Sort();

            sort.Ascending    = false;
            sort.PropertyName = "cell_number"; //如果有Map,则此次要填写Map对象的字段名称,而不是数据库表字段名称
            sorts.Add(sort);
            string       connStr     = "Server=rm-bp1gut3b938v3tms1.mysql.rds.aliyuncs.com;Port=3306;initial catalog=erp;uid=jijiuser;pwd=Fxft2016;Allow User Variables=True";
            MySqlAdapter mySqlClient = new MySqlAdapter(connStr);

            flowCell = mySqlClient.Get <JxcFlowCellItem>(pg, sorts).FirstOrDefault();

            return(flowCell);
        }
Exemple #38
0
		public ServiceResult<bool> DeleteBudgetCategory(int categoryId, DateTime month)
		{
			// TODO handle cascading deletes
			var result = new ServiceResult<bool>();
			bool deletionResult = false;

			// does category exist?
			var categoryResult = _categoryService.GetCategory(categoryId);
			if (categoryResult.HasErrors)
			{
				result.AddErrors(categoryResult);
				return result;
			}

			// does budget category exist?
			var predicates = new List<IPredicate>();
			predicates.Add(Predicates.Field<BudgetCategory>(x => x.Month, Operator.Eq, month));
			predicates.Add(Predicates.Field<BudgetCategory>(x => x.CategoryId, Operator.Eq, categoryId));
			var predicate = new PredicateGroup { Operator = GroupOperator.And, Predicates = predicates };
			var budgetCategory = _db.GetList<BudgetCategory>(predicate);

			// are there multiple budget categories with the same month?
			if (budgetCategory.Count() > 1)
			{
				result.AddError(ErrorType.Generic, "Multiple Budget Categories for month {0} exist", month.ToShortDateString());
				return result;
			}

			// is this an existing budget category?
			else if (budgetCategory.Count() == 1)
			{
				var existingBudgetCategory = budgetCategory.First();
				deletionResult = _db.Delete<BudgetCategory>(existingBudgetCategory);
			}

			result.Result = deletionResult;
			return result;
		}
Exemple #39
0
        protected void CarregarAtividadeChat(AtividadeNewViewModel model, Atividade atividade, string userId)
        {
            var where = new PredicateGroup {
                Operator = GroupOperator.And, Predicates = new List <IPredicate>()
            };
            where.Predicates.Add(Predicates.Field <Chat>(f => f.AtividadeId, Operator.Eq, atividade.Id));
            var chatAtividade = _chatServico.ObterPor(where);

            if (!chatAtividade.Any())
            {
                return;
            }

            var chat = _chatServico.ObterPorId(chatAtividade.FirstOrDefault().Id);

            if (chat.Id <= 0)
            {
                return;
            }
            model.Chat = new ChatViewModel(atividade.Id, chat.Id, atividade.AtendimentoId,
                                           atividade.PessoasJuridicasId, atividade.PessoasFisicasId, atividade.StatusAtividadeId);
            model.listaStatusAtividade = _statusAtividadeServico.ObterStatusAtividadeChat();

            if (atividade.AtendimentoId != null)
            {
                return;
            }
            var canal       = _canalServico.ObterPorNome("CHAT");
            var atendimento = new Atendimento(userId, _atendimentoServico.GerarNumeroProtocolo(DateTime.Now),
                                              canal != null ? canal.FirstOrDefault().Id : (int?)null, null);

            _atendimentoServico.Adicionar(atendimento);
            atividade.Atendimento = atendimento;

            atividade.AtendimentoId = atendimento.Id;
            model.atendimentoID     = atendimento.Id;
            _atividadeServico.Atualizar(atividade);
        }
Exemple #40
0
        protected override Expression VisitBinary(BinaryExpression node)
        {
            Expressions.Add(node);

            ExpressionType nt = node.NodeType;

            if (nt == ExpressionType.OrElse || nt == ExpressionType.AndAlso)
            {
                var pg = new PredicateGroup
                {
                    Predicates = new List <IPredicate>(),
                    Operator   = nt == ExpressionType.OrElse ? GroupOperator.Or : GroupOperator.And
                };
                CurrentGroup.Predicates.Add(pg);
                _predicateGroupStack.Push(CurrentGroup);
                CurrentGroup = pg;
            }

            Visit(node.Left);

            if (node.Left is MemberExpression)
            {
                IFieldPredicate field = GetCurrentField();
                field.Operator = DetermineOperator(node);

                if (nt == ExpressionType.NotEqual)
                {
                    field.Not = true;
                }
            }

            Visit(node.Right);
            if (nt == ExpressionType.OrElse || nt == ExpressionType.AndAlso)
            {
                CurrentGroup = _predicateGroupStack.Pop();
            }
            return(node);
        }
Exemple #41
0
        private bool IsRepeat(Table table)
        {
            PredicateGroup gp = new PredicateGroup {
                Operator = GroupOperator.And, Predicates = new List <IPredicate>()
            };
            //表名、别名
            PredicateGroup gp1 = new PredicateGroup {
                Operator = GroupOperator.Or, Predicates = new List <IPredicate>()
            };

            gp1.Predicates.Add(Predicates.Field <Table>(t => t.tbname, Operator.Eq, table.tbname));
            gp1.Predicates.Add(Predicates.Field <Table>(t => t.alias, Operator.Eq, table.alias));
            gp.Predicates.Add(gp1);
            //排除主键
            if (table.id.IsNotEmpty())
            {
                gp.Predicates.Add(Predicates.Field <Table>(t => t.id, Operator.Eq, table.id, true));//主键不等
            }

            var count = _tableRep.Count(gp);

            return(count > 0);
        }
        public PageResult <UserAccountDto> GetUserAccountDto(PageQueryCondition <ProtocolQueryUserAccount, PageQuery> query)
        {
            PredicateGroup group = new PredicateGroup();

            group.Operator = GroupOperator.And;
            if (!string.IsNullOrEmpty(query.Condition.OrganizeId))
            {
                group.Predicates.Add(Predicates.Field <UserAccount>(d => d.OrganizationId, Operator.Eq, query.Condition.OrganizeId));
            }
            if (!string.IsNullOrEmpty(query.Condition.DepartmentId))
            {
                group.Predicates.Add(Predicates.Field <UserAccount>(d => d.DepartmentId, Operator.Eq, query.Condition.DepartmentId));
            }
            if (!string.IsNullOrEmpty(query.Condition.UserId))
            {
                group.Predicates.Add(Predicates.Field <UserAccount>(d => d.Id, Operator.Eq, query.Condition.UserId));
            }
            if (!string.IsNullOrEmpty(query.Condition.Filter))
            {
                group.Predicates.Add(Predicates.Field <UserAccount>(d => d.Name, Operator.Like, query.Condition.Filter));
            }
            return(Unit.UserRepository.GetUserAccount(group, query.Query).ToPageModel <GIS.Authority.Entity.UserAccount, UserAccountDto>());
        }
Exemple #43
0
 ///<summary>
 ///刪除使用者資料
 ///</summary>
 public static ReturnMessage <string> DeleteUser(string sEmp)
 {
     try
     {
         using (var conn = new SqlConnection(strConnOracle))
         {
             var pg = new PredicateGroup {
                 Operator = GroupOperator.And, Predicates = new List <IPredicate>()
             };
             pg.Predicates.Add(Predicates.Field <Emp>(f => f.No, Operator.Eq, sEmp));
             conn.Delete <Emp>(pg);
         }
         return(new ReturnMessage <String> {
             Result = "1", Message = "成功", ReturnList = null
         });
     }
     catch (Exception ex)
     {
         return(new ReturnMessage <String> {
             Result = "0", Message = ex.Message, ReturnList = null
         });
     }
 }
        /// <summary>
        ///     私有方法
        /// </summary>
        /// <param name="array"></param>
        /// <returns></returns>
        private async Task <List <TopMenusViewModel> > LoadData(long[] array)
        {
            var menuid = await _roleManage.GetRoleMenuByArrayAsync(array);

            Expression <Func <Menu, bool> > where =
                w => w.IsMenu && menuid.Contains(w.Id) && w.IsValid;

            var predicate = new PredicateGroup <Menu>();

            predicate.AddPredicate(true, where);

            var menus = await _menuManage
                        .GetMenuListAsync(predicate.Predicates);

            var topMenus          = menus.ToList().Where(x => x.ParentId == null);
            var topMenusViewModel = topMenus.MapTo <List <TopMenusViewModel> >();

            foreach (var item in topMenusViewModel)
            {
                item.ChildMenus.AddRange(BuildSideBar(item.Id, item.Code, menus));
            }
            return(topMenusViewModel);
        }
        public IList<Page> List(Guid? parentId = null, bool includeParentInResults = false, bool includeUnpublished = false, bool includeInactive = false)
        {
            IList<Page> pages = new List<Page>();
            using (var con = _connectionManager.GetConnection())
            {
                var sort = new List<ISort>()
                {
                    Predicates.Sort<Page>(p => p.Path, true)
                };

                PredicateGroup mainGroup = new PredicateGroup()
                {
                    Operator = GroupOperator.And,
                    Predicates = new List<IPredicate>()
                };

                PredicateGroup gr = new PredicateGroup(){Operator = GroupOperator.And,Predicates = new List<IPredicate>()};
                mainGroup.Predicates.Add(gr);

                if (!includeUnpublished)
                {
                    gr.Predicates.Add(Predicates.Field<Page>(p => p.PublishDateUtc, Operator.Eq, null, true));
                    gr.Predicates.Add(Predicates.Field<Page>(p=>p.IsApproved,Operator.Eq,true));
                }
                if (!includeInactive)
                {
                    gr.Predicates.Add(Predicates.Field<Page>(p => p.IsActive, Operator.Eq, true));
                }
                if (parentId.HasValue)
                {
                    PredicateGroup gr2 = new PredicateGroup() { Operator = GroupOperator.Or, Predicates = new List<IPredicate>() };
                    gr2.Predicates.Add(Predicates.Field<Page>(p=>p.ParentId,Operator.Eq, parentId.Value));
                    if(includeParentInResults)
                        gr2.Predicates.Add(Predicates.Field<Page>(p => p.Id, Operator.Eq, parentId.Value));

                    mainGroup.Predicates.Add(gr2);
                }
               // mainGroup.Predicates.Add(Predicates.Field<Page>(f=>f.Path,Operator.Eq, null,true));
                pages = con.GetList<Page>(mainGroup, sort).ToList();
                con.Close();
            }
            return pages;
        }
 public bool DeleteForumActiveDirectoryMapping(Model.Entities.ForumActiveDirectoryMapping forumActiveDirectoryMapping)
 {
     var predicateGroup = new PredicateGroup { Operator = GroupOperator.And, Predicates = new List<IPredicate>() };
     predicateGroup.Predicates.Add(Predicates.Field<Model.Entities.NewJoinees>(f => f.Id, Operator.Eq, forumActiveDirectoryMapping.Id));
     return SqlHelper.Delete<Model.Entities.ForumActiveDirectoryMapping>(predicateGroup);
 }
 public bool DeleteForumsSummary(ForumSummary forumSummary)
 {
     var pg = new PredicateGroup { Operator = GroupOperator.And, Predicates = new List<IPredicate>() };
     pg.Predicates.Add(Predicates.Field<ForumSummary>(f => f.Id, Operator.Eq, forumSummary.Id));
     return SqlHelper.Delete<ForumSummary>(pg);
 }
Exemple #48
0
 /// <summary>
 /// Lists the specified predicate group.
 /// </summary>
 /// <param name="predicateGroup">The predicate group.</param>
 /// <returns>A list.</returns>
 /// <example>
 /// Example:
 /// var pg = new PredicateGroup { Operator = GroupOperator.And, Predicates = new List&lt;IPredicate&gt;() };
 /// pg.Predicates.Add(Predicates.Field&lt;Task&gt;(f => f.Active, Operator.Eq, true));
 /// pg.Predicates.Add(Predicates.Field&lt;Task&gt;(f => f.LastName, Operator.Like, "Br%"));
 /// IEnumerable&lt;Task&gt; list = repository.List&lt;Task&gt;(pg);
 /// https://github.com/tmsmith/Dapper-Extensions/wiki/Predicates
 /// .
 /// </example>
 public IEnumerable<Task> GetList(PredicateGroup predicateGroup)
 {
     using (var con = this._connection.Create())
     {
         con.Open();
         return con.GetList<Task>(predicateGroup).ToList();
     }
 }
Exemple #49
0
 private void SaveLike(HttpContext context)
 {
     int id = int.Parse(context.Request.Params["id"]);
     bool liked = bool.Parse(context.Request.Params["liked"]);
     if (liked)
     {
         Data.dbml.Likes l = new Data.dbml.Likes();
         l.BoardsImagesMappingID = id;
         l.UserID = Common.UserID.Value;
         GetDataContext2.Likes.InsertOnSubmit(l);
         GetDataContext2.SubmitChanges();
     }
     else
     {
         PredicateGroup group = new PredicateGroup() { Operator = GroupOperator.And, Predicates = new List<IPredicate>() };
         group.Predicates.Add(Predicates.Field<Data.Standalone.Likes>(f => f.BoardsImagesMappingID, Operator.Eq, id));
         group.Predicates.Add(Predicates.Field<Data.Standalone.Likes>(f => f.UserID, Operator.Eq, Common.UserID));
         SqlConnection.Delete<Data.Standalone.Likes>(group);
     }
     UpdateUPCount();
 }
 public bool DeleteBusinessUpdates(Model.Entities.BusinessUpdates businessUpdates)
 {
     var predicateGroup = new PredicateGroup { Operator = GroupOperator.And, Predicates = new List<IPredicate>() };
     predicateGroup.Predicates.Add(Predicates.Field<Model.Entities.BusinessUpdates>(f => f.Id, Operator.Eq, businessUpdates.Id));
     return SqlHelper.Delete<Model.Entities.BusinessUpdates>(predicateGroup);
 }
 public bool DeleteNewJoinee(Model.Entities.NewJoinees newJoinee)
 {
     var predicateGroup = new PredicateGroup { Operator = GroupOperator.And, Predicates = new List<IPredicate>() };
     predicateGroup.Predicates.Add(Predicates.Field<Model.Entities.NewJoinees>(f => f.Id, Operator.Eq, newJoinee.Id));
     return SqlHelper.Delete<Model.Entities.NewJoinees>(predicateGroup);
 }
 public bool DeleteVacancy(Model.Entities.Vacancy vacancy)
 {
     var predicateGroup = new PredicateGroup { Operator = GroupOperator.And, Predicates = new List<IPredicate>() };
     predicateGroup.Predicates.Add(Predicates.Field<Model.Entities.UpcomingEvents>(f => f.Id, Operator.Eq, vacancy.Id));
     return SqlHelper.Delete<Model.Entities.Vacancy>(predicateGroup);
 }
Exemple #53
0
 /// <summary>
 /// Gets the list.
 /// </summary>
 /// <param name="startDate">The start date.</param>
 /// <param name="endDate">The end date.</param>
 /// <returns>
 /// A list.
 /// </returns>
 public IEnumerable<Task> ListByDate(DateTime startDate, DateTime endDate)
 {
     var pg = new PredicateGroup { Operator = GroupOperator.And, Predicates = new List<IPredicate>() };
     pg.Predicates.Add(Predicates.Field<Task>(f => f.TaskDate, Operator.Gt, startDate));
     pg.Predicates.Add(Predicates.Field<Task>(f => f.TaskDate, Operator.Lt, endDate));
     return this.GetList(pg).ToList();
 }
 public bool DeleteModules(Model.Entities.Module module)
 {
     var predicateGroup = new PredicateGroup { Operator = GroupOperator.And, Predicates = new List<IPredicate>() };
     predicateGroup.Predicates.Add(Predicates.Field<Model.Entities.Module>(f => f.Id, Operator.Eq, module.Id));
     return SqlHelper.Delete<Model.Entities.Module>(predicateGroup);
 }
        public Page GetHomePage()
        {
            Page node = null;
            using (var con = _connectionManager.GetConnection())
            {
                PredicateGroup mainGroup = new PredicateGroup()
                {
                    Operator = GroupOperator.Or,
                    Predicates = new List<IPredicate>()
                };
                PredicateGroup secondGroup = new PredicateGroup()
                {
                    Operator = GroupOperator.And,
                    Predicates = new List<IPredicate>()
                };
                secondGroup.Predicates.Add(Predicates.Field<Page>(p=>p.IsHomePage,Operator.Eq,true));
                secondGroup.Predicates.Add(Predicates.Field<Page>(p => p.IsActive, Operator.Eq, true));
                secondGroup.Predicates.Add(Predicates.Field<Page>(p => p.IsApproved, Operator.Eq, true));
                secondGroup.Predicates.Add(Predicates.Field<Page>(p => p.PublishDateUtc, Operator.Le, DateTime.UtcNow));
                mainGroup.Predicates.Add(Predicates.Field<Page>(p => p.Path, Operator.Eq, null));
                mainGroup.Predicates.Add(secondGroup);

                 var sort = new List<ISort>()
                {
                    Predicates.Sort<Page>(p => p.IsHomePage,false)
                };
                node = con.GetList<Page>(mainGroup, sort).FirstOrDefault();

                con.Close();
            }
            return node;
        }
 public bool DeletePermission(Permission permission)
 {
     var predicateGroup = new PredicateGroup { Operator = GroupOperator.And, Predicates = new List<IPredicate>() };
     predicateGroup.Predicates.Add(Predicates.Field<Model.Entities.Permission>(f => f.Id, Operator.Eq, permission.Id));
     return SqlHelper.Delete<Model.Entities.Permission>(predicateGroup);
 }
 public Model.Entities.UpcomingEvents GetUpcomingEvents(Model.Entities.UpcomingEvents upcomingEvents)
 {
     var predicateGroup = new PredicateGroup { Operator = GroupOperator.And, Predicates = new List<IPredicate>() };
     predicateGroup.Predicates.Add(Predicates.Field<Model.Entities.UpcomingEvents>(f => f.Id, Operator.Eq, upcomingEvents.Id));
     return SqlHelper.Find<Model.Entities.UpcomingEvents>(predicateGroup);
 }
 public Permission GetPermission(Permission permission)
 {
     var predicateGroup = new PredicateGroup { Operator = GroupOperator.And, Predicates = new List<IPredicate>() };
     predicateGroup.Predicates.Add(Predicates.Field<Model.Entities.Permission>(f => f.LdapUserName, Operator.Eq, permission.LdapUserName));
     return SqlHelper.Find<Model.Entities.Permission>(predicateGroup);
 }
 public bool DeleteStaticContents(StaticContents staticContents)
 {
     var predicateGroup = new PredicateGroup { Operator = GroupOperator.And, Predicates = new List<IPredicate>() };
     predicateGroup.Predicates.Add(Predicates.Field<StaticContents>(f => f.Guid, Operator.Eq, staticContents.Guid));
     return SqlHelper.Delete<StaticContents>(predicateGroup);
 }
Exemple #60
0
        public IEnumerable<CustomerTransaction> GetTransactions(Guid? customerId, DateTimeOffset? fromDate, DateTimeOffset? toDate)
        {
            using (var connectionScope = new ConnectionScope())
            {
                var where = new PredicateGroup { Operator = GroupOperator.And, Predicates = new List<IPredicate>() };
                if (customerId.HasValue)
                    where.Predicates.Add(Predicates.Field<CustomerTransaction>(f => f.CustomerId, Operator.Eq, customerId.Value));
                if (fromDate.HasValue)
                    where.Predicates.Add(Predicates.Field<CustomerTransaction>(f => f.DateTime, Operator.Ge, fromDate.Value));
                if (toDate.HasValue)
                    where.Predicates.Add(Predicates.Field<CustomerTransaction>(f => f.DateTime, Operator.Le, toDate.Value));

                return connectionScope.Connection.GetList<CustomerTransaction>(where.Predicates.Any() ? where : null).ToList();
            }
        }