Exemple #1
0
        public ApplicationRole GetById(long id, AasApplicationRoleSO search)
        {
            ApplicationRole result = null;

            try
            {
                bool valid = true;
                valid = valid && IsGreaterThanZero(id);
                if (valid)
                {
                    using (var ctx = new Base.AppContext())
                    {
                        var query = ctx.ApplicationRoles.AsQueryable().Where(p => p.Id == id);
                        if (search.listApplicationRoleExpression != null && search.listApplicationRoleExpression.Count > 0)
                        {
                            foreach (var item in search.listApplicationRoleExpression)
                            {
                                query = query.Where(item);
                            }
                        }
                        result = query.SingleOrDefault();
                    }
                }
            }
            catch (Exception ex)
            {
                Logging(LogUtil.TraceData("id", id) + LogUtil.TraceData("search", search), LogType.Error);
                LogSystem.Error(ex);
                result = null;
            }
            return(result);
        }
Exemple #2
0
        public List <ApplicationRole> Get(AasApplicationRoleSO search, CommonParam param)
        {
            List <ApplicationRole> list = new List <ApplicationRole>();

            try
            {
                bool valid = true;
                valid = valid && IsNotNull(param);
                if (valid)
                {
                    using (var ctx = new Base.AppContext())
                    {
                        var query = ctx.ApplicationRoles.AsQueryable();
                        if (search.listApplicationRoleExpression != null && search.listApplicationRoleExpression.Count > 0)
                        {
                            foreach (var item in search.listApplicationRoleExpression)
                            {
                                query = query.Where(item);
                            }
                        }

                        if (!string.IsNullOrWhiteSpace(search.OrderField) && !string.IsNullOrWhiteSpace(search.OrderDirection))
                        {
                            if (!param.Start.HasValue || !param.Limit.HasValue)
                            {
                                list = query.OrderByProperty(search.OrderField, search.OrderDirection).ToList();
                            }
                            else
                            {
                                param.Count = (from r in query select r).Count(); query = query.OrderByProperty(search.OrderField, search.OrderDirection);
                                if (param.Count <= param.Limit.Value && param.Start.Value == 0)
                                {
                                    list = query.ToList();
                                }
                                else
                                {
                                    list = query.Skip(param.Start.Value).Take(param.Limit.Value).ToList();
                                }
                            }
                        }
                        else
                        {
                            list = query.ToList();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Logging(LogUtil.TraceData("search", search) + LogUtil.TraceData("param", param), LogType.Error);
                LogSystem.Error(ex);
                list.Clear();
            }
            return(list);
        }
        public ApplicationRole GetById(long id, AasApplicationRoleSO search)
        {
            ApplicationRole result = null;

            try
            {
                result = GetWorker.GetById(id, search);
            }
            catch (Exception ex)
            {
                LogSystem.Error(ex);
                result = null;
            }

            return(result);
        }
        public List <ApplicationRole> Get(AasApplicationRoleSO search, CommonParam param)
        {
            List <ApplicationRole> result = new List <ApplicationRole>();

            try
            {
                result = GetWorker.Get(search, param);
            }
            catch (Exception ex)
            {
                param.HasException = true;
                LogSystem.Error(ex);
                result.Clear();
            }
            return(result);
        }
Exemple #5
0
        internal AasApplicationRoleSO Query()
        {
            AasApplicationRoleSO search = new AasApplicationRoleSO();

            try
            {
                #region Abstract Base
                if (this.Id.HasValue)
                {
                    listExpression.Add(o => o.Id == this.Id.Value);
                }
                if (this.IsActive.HasValue)
                {
                    listExpression.Add(o => o.IsActive == this.IsActive.Value);
                }
                if (this.CreateTimeFrom.HasValue)
                {
                    listExpression.Add(o => o.CreateTime.Value >= this.CreateTimeFrom.Value);
                }
                if (this.CreateTimeFromGreater.HasValue)
                {
                    listExpression.Add(o => o.CreateTime.Value > this.CreateTimeFromGreater.Value);
                }
                if (this.CreateTimeTo.HasValue)
                {
                    listExpression.Add(o => o.CreateTime.Value <= this.CreateTimeTo.Value);
                }
                if (this.CreateTimeToLess.HasValue)
                {
                    listExpression.Add(o => o.CreateTime.Value < this.CreateTimeToLess.Value);
                }
                if (this.ModifyTimeFrom.HasValue)
                {
                    listExpression.Add(o => o.ModifyTime.Value >= this.ModifyTimeFrom.Value);
                }
                if (this.ModifyTimeFromGreater.HasValue)
                {
                    listExpression.Add(o => o.ModifyTime.Value > this.ModifyTimeFromGreater.Value);
                }
                if (this.ModifyTimeTo.HasValue)
                {
                    listExpression.Add(o => o.ModifyTime.Value <= this.ModifyTimeTo.Value);
                }
                if (this.ModifyTimeToLess.HasValue)
                {
                    listExpression.Add(o => o.ModifyTime.Value < this.ModifyTimeToLess.Value);
                }
                if (!String.IsNullOrEmpty(this.Creator))
                {
                    listExpression.Add(o => o.Creator == this.Creator);
                }
                if (!String.IsNullOrEmpty(this.Modifier))
                {
                    listExpression.Add(o => o.Modifier == this.Modifier);
                }
                if (this.Ids != null)
                {
                    listExpression.Add(o => this.Ids.Contains(o.Id));
                }
                #endregion

                if (this.ApplicationId.HasValue)
                {
                    listExpression.Add(o => o.ApplicationId == this.ApplicationId.Value);
                }
                if (this.ApplicationIds != null)
                {
                    listExpression.Add(o => this.ApplicationIds.Contains(o.ApplicationId));
                }
                if (this.RoleId.HasValue)
                {
                    listExpression.Add(o => o.RoleId == this.RoleId.Value);
                }
                if (this.RoleIds != null)
                {
                    listExpression.Add(o => this.RoleIds.Contains(o.RoleId));
                }

                search.listApplicationRoleExpression.AddRange(listExpression);
                search.OrderField     = this.OrderField;
                search.OrderDirection = this.OrderDirection;
            }
            catch (Exception ex)
            {
                LogSystem.Error(ex);
                search.listApplicationRoleExpression.Clear();
                search.listApplicationRoleExpression.Add(o => o.Id == NegativeId);
            }
            return(search);
        }