/// <summary> /// Gets all action log. /// </summary> /// <param name="totalRecords">The total records.</param> /// <param name="currentPage">The current page.</param> /// <param name="pageSize">Size of the page.</param> /// <param name="sortBy">The sort by.</param> /// <param name="descending">if set to <c>true</c> [descending].</param> /// <param name="loginName">The login name.</param> /// <param name="actionContent">Action Content.</param> /// <param name="actionType">Action Type.</param> /// <returns></returns> public IEnumerable <ActionLog> GetAllActionLogItems(out int totalRecords, int currentPage = 1, int pageSize = 25, bool descending = true, string sortBy = "ActionTime", string loginName = "", string actionContent = "", LogActionType?actionType = null) { var spec = LogQuery.WithAllAct(); spec = !string.IsNullOrEmpty(loginName) ? spec.And(LogQuery.WithLoginNameAct(loginName)) : spec; spec = !string.IsNullOrEmpty(actionContent) ? spec.And(LogQuery.WithActionContentAct(actionContent)) : spec; spec = actionType.HasValue ? spec.And(LogQuery.WithActionTypeAct(actionType.Value)) : spec; totalRecords = _actionLog.Count(spec); var sort = Context.Filters.Sort <ActionLog, DateTime>(al => al.ActionTime, true); switch (sortBy) { case "LoginName": sort = Context.Filters.Sort <ActionLog, string>(al => al.LoginName, descending); break; case "ActionContent": sort = Context.Filters.Sort <ActionLog, string>(al => al.ActionContent, descending); break; case "ActionTime": sort = Context.Filters.Sort <ActionLog, DateTime>(al => al.ActionTime, descending); break; } var pager = Context.Filters.Page <ActionLog>(currentPage, pageSize); return(_actionLog.Find(spec, sort, pager)); }