Ejemplo n.º 1
0
        public object List(int formId = 0, int userId = 0, DateTime?beginTime = null, int page = 1, int rows = 10)
        {
            var parameter = new FeedParameter
            {
                Page      = new PageParameter(page, rows),
                FormId    = formId,
                BeginTime = DateTime.Today.AddDays(-15),
                ToUserId  = Identity.ID
            };
            var list = Core.FeedManager.GetList(parameter).GroupBy(e => new { e.Info, e.FromUserId, e.ToUserId }).Select(g => g.FirstOrDefault()).SetPage(parameter.Page);

            return(new PagingResult
            {
                List = list.Select(e => new
                {
                    e.ID,
                    FormId = e.Info == null ? 0 : e.Info.FormId,
                    FormName = e.Info == null ? null : e.Info.Form.Name,
                    e.FromUserId,
                    FromUser = e.FromUser == null ? null : e.FromUser.RealName,
                    ToUser = e.ToUser == null ? null : e.ToUser.RealName,
                    e.ToUserId,
                    e.InfoId,
                    FlowStep = e.Info == null ? null : e.Info.FlowStep,
                    Action = e.Action.GetDescription(),
                    e.Title,
                    e.Description,
                    e.CreateTime,
                    TypeId = (int)e.Type,
                    Type = e.Type.GetDescription()
                }),
                Page = parameter.Page
            });
        }
Ejemplo n.º 2
0
        public IEnumerable <Feed> GetList(FeedParameter parameter)
        {
            var query = DB.Feeds.Where(e => !e.Deleted);

            if (parameter.FormId > 0)
            {
                query = query.Where(e => e.Info.FormId == parameter.FormId);
            }
            if (parameter.UserId > 0)
            {
                query = query.Where(e => e.FromUserId == parameter.UserId || e.ToUserId == parameter.UserId);
            }
            if (parameter.InfoIds != null)
            {
                query = query.Where(e => parameter.InfoIds.Contains(e.InfoId) || e.InfoId == 0);
            }
            if (parameter.FromUserId > 0)
            {
                query = query.Where(e => e.FromUserId == parameter.FromUserId);
            }
            if (parameter.ToUserId > 0)
            {
                query = query.Where(e => e.ToUserId == parameter.ToUserId);
            }
            if (parameter.BeginTime.HasValue)
            {
                query = query.Where(e => e.CreateTime > parameter.BeginTime.Value);
            }
            return(query.OrderByDescending(e => e.ID));
        }
Ejemplo n.º 3
0
        public List <FeedView> Search(FeedParameter parameter)
        {
            var query = Db.FeedViews.AsQueryable();

            if (parameter.Old.HasValue)
            {
                query = query.Where(e => e.Old == parameter.Old.Value);
            }
            if (parameter.New.HasValue)
            {
                query = query.Where(e => e.New == parameter.New.Value);
            }
            if (parameter.HasRead.HasValue)
            {
                query = query.Where(e => e.HasRead == parameter.HasRead.Value);
            }
            if (!string.IsNullOrEmpty(parameter.ELName))
            {
                query = query.Where(e => e.ELName.ToLower().Contains(parameter.ELName.ToLower()));
            }


            query = query.OrderByDescending(e => e.CreateTime).SetPage(parameter.Page);
            return(query.ToList());
        }
        // GET: Feed
        public ActionResult Index(
            string elName = null, bool?hasRead = null, GradeDegree?Old = null, GradeDegree?New = null,
            int page      = 1, int rows        = 20)
        {
            var parameter = new FeedParameter
            {
                ELName  = elName,
                Old     = Old,
                New     = New,
                HasRead = hasRead,
                Page    = new PageParameter(page, rows)
            };
            var list = Core.FeedManager.Search(parameter);

            ViewBag.List      = list;
            ViewBag.Parameter = parameter;
            return(View());
        }