예제 #1
0
        public JsonResult List(int page, int rows, string title, string BeginTime = "", string EndTime = "")
        {
            LawInfoQuery model = new LawInfoQuery();

            model.Title = title;
            DateTime dt;

            if (DateTime.TryParse(BeginTime, out dt) && DateTime.TryParse(EndTime, out dt))
            {
                model.BeginTime = DateTime.Parse(BeginTime);
                model.EndTime   = DateTime.Parse(EndTime);
                model.PageNo    = page;
                model.PageSize  = rows;
            }
            else
            {
                model.PageNo   = page;
                model.PageSize = rows;
            }
            PageModel <LawInfo> opModel = ServiceHelper.Create <ILawInfoService>().GetLawInfos(model, 0);
            var array =
                from item in opModel.Models.ToArray()
                select new { Id = item.Id, Title = item.Title, CreateTime = item.CreateTime, Status = item.Status };

            return(Json(new { rows = array, total = opModel.Total }));
        }
예제 #2
0
        public PageModel <LawInfo> GetLawInfos(LawInfoQuery model, long?userId)
        {
            int pageNum = 0;
            IQueryable <LawInfo> lawInfo = from item in base.context.LawInfo
                                           select item;

            string begin = model.BeginTime.ToString("yyyy/MM/dd");
            string end   = model.EndTime.ToString("yyyy/MM/dd");

            if (!string.IsNullOrWhiteSpace(begin) && !begin.Equals("0001/01/01") && !string.IsNullOrWhiteSpace(end) && !end.Equals("0001/01/01"))
            {
                lawInfo = (from a in lawInfo where a.CreateTime > model.BeginTime && a.CreateTime < model.EndTime select a);
            }
            if (!string.IsNullOrWhiteSpace(model.Title))
            {
                lawInfo = (from a in lawInfo where a.Title.Contains(model.Title) select a);
            }

            lawInfo = lawInfo.GetPage(out pageNum, model.PageNo, model.PageSize, (IQueryable <LawInfo> d) =>
                                      from o in d
                                      orderby o.CreateTime descending
                                      select o);
            foreach (LawInfo list in lawInfo.ToList())
            {
                if (list.UserId != 0)
                {
                    ManagerInfo manaInfo = context.ManagerInfo.FirstOrDefault((ManagerInfo m) => m.Id == list.Auditor && m.ShopId == 0);
                    list.UserName = (manaInfo == null ? "" : manaInfo.UserName);
                    ChemCloud_Dictionaries dicts = context.ChemCloud_Dictionaries.FirstOrDefault((ChemCloud_Dictionaries m) => m.DictionaryTypeId == 10 && m.DValue == list.LanguageType.ToString());
                    list.Language = dicts.DKey;
                }
            }
            return(new PageModel <LawInfo>
            {
                Models = lawInfo,
                Total = pageNum
            });
        }