/// <summary> /// Query the notices by conditions.通过查询条件组来查询notice /// </summary> /// <param name="condition">The condition.</param> /// <returns>IQueryable<ModNotices>.</returns> public IQueryable <ModNotices> QueryNoticesByConditions(SearchNoticeCondition condition) { string receiver, storeCode; receiver = condition.Receiver; storeCode = condition.StoreCode; //IQueryable<ModNotices> itemResult; var context = GetDb(); //{ // itemResult = (from child in context.ModNoticeReceivers // join main in context.ModNotices on child.NoticeId equals main.Id // where child.Receiver == receiver // && (string.IsNullOrEmpty(condition.ProcessId) || main.ProcessId.Contains( condition.ProcessId) ) // && (string.IsNullOrEmpty(condition.Title) || main.Title.Contains(condition.Title)) // && (string.IsNullOrEmpty(condition.SenderName) || main.SenderNameENUS.Contains(condition.SenderName) || main.SenderNameZHCN.Contains(condition.SenderName)) // && (!condition.DateFrom.HasValue || main.CreatedTime >= condition.DateFrom ) // && (!condition.DateTo.HasValue || main.CreatedTime <= condition.DateTo ) // || (from role in context.V_RoleEmployeeRelation where role.Code == receiver select role.Code).Contains(child.Receiver) // || (from posit in context.V_StorePostionRelation // where (!string.IsNullOrEmpty(storeCode) && posit.Code == storeCode && posit.EmployeeAccount == receiver) // || (string.IsNullOrEmpty(storeCode) && posit.EmployeeAccount == receiver) // select posit.PositionCode // ).Contains(child.Receiver) // select main).Distinct(); //} return(null); }
public IHttpActionResult GetNoticesList(int pageSize, int pageIndex, string receiver, SearchNoticeCondition condtion) { var queryString = HttpContext.Current.Request.QueryString; if (!string.IsNullOrEmpty(receiver)) { condtion.Receiver = receiver; } var bll = new ModNotices(); var result = bll.QueryNoticesByConditions(condtion); var skipSize = pageSize * (pageIndex - 1); int totalItems = result.Count(); var list = result.OrderByDescending(c => c.CreatedTime).Skip(skipSize) .Take(pageSize).ToList(); return(Ok(new PagedDataSource(totalItems, list.ToArray()))); }