public OperationResultList <Notification> SearchNotifications() { var executionStart = DateTime.Now; var options = new FeedOptions() { MaxItemCount = 50 }; using (var client = _db.NewClient()) { var query = _db.QueryNotification(client, options).Where(t => t.Id != null); var dataLength = query.Count(); var results = query.OrderByDescending(n => n.RegistrationDate).Take(50).ToList(); return(new OperationResultList <Notification>(results) { DataLength = dataLength, ExecutionTime = Convert.ToInt32(DateTime.Now.Subtract(executionStart).TotalMilliseconds) }); } }
public OperationResultList <SimpleTask> SearchTasks(SimpleTaskQuery request = null) { var executionStart = DateTime.Now; request = request ?? new SimpleTaskQuery(); request.MaxRecords = request.MaxRecords > 0 ? request.MaxRecords : 50; if (request.Order == null || request.Order.Count == 0) { request.Order = new List <DataOrderItem>() { new DataOrderItem("RegistrationDateTime", true) }; } var options = new FeedOptions() { MaxItemCount = request.MaxRecords }; using (var client = _db.NewClient()) { var query = _db.QueryTask(client, options).Where(t => t.Id != null); if (!string.IsNullOrEmpty(request.Text)) { query = query.Where(t => t.Title.ToLower().Contains(request.Text.ToLower()) || t.Description.ToLower().Contains(request.Text.ToLower()) ); } var dataLength = query.Count(); var results = query.OrderBy(request.Order).Take(request.MaxRecords).ToList(); return(new OperationResultList <SimpleTask>(results) { DataLength = dataLength, ExecutionTime = Convert.ToInt32(DateTime.Now.Subtract(executionStart).TotalMilliseconds) }); } }