diff --git a/Bootstrap.DataAccess.MongoDB/Exceptions.cs b/Bootstrap.DataAccess.MongoDB/Exceptions.cs index c0e54c5a..dab2fa63 100644 --- a/Bootstrap.DataAccess.MongoDB/Exceptions.cs +++ b/Bootstrap.DataAccess.MongoDB/Exceptions.cs @@ -65,6 +65,30 @@ namespace Bootstrap.DataAccess.MongoDB public override Page RetrievePages(PaginationOption po, DateTime? startTime, DateTime? endTime) { var exceps = DbManager.Exceptions.Find(FilterDefinition.Empty).ToList(); + // sort + var orderProxy = po.Order == "asc" ? + new Func, List>(p => exceps.OrderBy(p).ToList()) : + new Func, List>(p => exceps.OrderByDescending(p).ToList()); + + var logTimeProxy = po.Order == "asc" ? + new Func, List>(p => exceps.OrderBy(p).ToList()) : + new Func, List>(p => exceps.OrderByDescending(p).ToList()); + + switch (po.Sort) + { + case "ErrorPage": + exceps = orderProxy(ex => ex.ErrorPage); + break; + case "UserId": + exceps = orderProxy(ex => ex.UserId); + break; + case "UserIp": + exceps = orderProxy(ex => ex.UserIp); + break; + case "LogTime": + exceps = logTimeProxy(ex => ex.LogTime); + break; + } return new Page() { Context = exceps,