public IHttpActionResult MarkAllAsRead() { var criteria = new PushNotificationSearchCriteria { OnlyNew = true, Start = 0, Count = int.MaxValue }; var retVal = _pushNotifier.SearchNotifies(User.Identity.Name, criteria); foreach (var notifyEvent in retVal.NotifyEvents) { notifyEvent.IsNew = false; _pushNotifier.Upsert(notifyEvent); } return(Ok(retVal)); }
public async Task <ActionResult <PushNotificationSearchResult> > MarkAllAsRead() { var criteria = new PushNotificationSearchCriteria { OnlyNew = true, Skip = 0, Take = int.MaxValue }; var retVal = _pushNotifier.SearchNotifies(User.Identity.Name, criteria); foreach (var notifyEvent in retVal.NotifyEvents) { notifyEvent.IsNew = false; await _pushNotifier.SendAsync(notifyEvent); } return(Ok(retVal)); }
private IndexProgressPushNotification GetNotification(string currentUserName, string notificationId) { IndexProgressPushNotification notification = null; if (!string.IsNullOrEmpty(notificationId)) { var searchCriteria = new PushNotificationSearchCriteria { Ids = new[] { notificationId } }; var searchResult = _pushNotificationManager.SearchNotifies(currentUserName, searchCriteria); notification = searchResult?.NotifyEvents.OfType <IndexProgressPushNotification>().FirstOrDefault(); } var result = notification ?? CreateNotification(currentUserName, notificationId); return(result); }
public PushNotificationSearchResult SearchNotifies(string userId, PushNotificationSearchCriteria criteria) { var query = _innerList.OrderByDescending(x => x.Created).Where(x => x.Creator == userId).AsQueryable(); if (criteria.Ids != null && criteria.Ids.Any()) { query = query.Where(x => criteria.Ids.Contains(x.Id)); } if (criteria.OnlyNew) { query = query.Where(x => x.IsNew); } if (criteria.StartDate != null) { query = query.Where(x => x.Created >= criteria.StartDate); } if (criteria.EndDate != null) { query = query.Where(x => x.Created <= criteria.EndDate); } var sortInfos = criteria.SortInfos; if (sortInfos.IsNullOrEmpty()) { sortInfos = new[] { new SortInfo { SortColumn = ReflectionUtility.GetPropertyName <PushNotification>(x => x.Created), SortDirection = SortDirection.Descending } }; } var retVal = new PushNotificationSearchResult { TotalCount = query.Count(), NewCount = query.Count(x => x.IsNew), NotifyEvents = query.Skip(criteria.Skip).Take(criteria.Take).ToList() }; return(retVal); }
public IHttpActionResult Search(PushNotificationSearchCriteria criteria) { var retVal = _pushNotifier.SearchNotifies(User.Identity.Name, criteria); return(Ok(retVal)); }
public virtual PushNotificationSearchResult SearchNotifies(string userId, PushNotificationSearchCriteria criteria) { var retVal = _storage.SearchPushNotifications(userId, criteria); return(retVal); }
/// <summary> /// Search push notifications /// </summary> /// <exception cref="VirtoCommerce.Platform.Client.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="criteria">Search parameters.</param> /// <returns>Task of ApiResponse (PushNotificationSearchResult)</returns> public async System.Threading.Tasks.Task<ApiResponse<PushNotificationSearchResult>> PushNotificationSearchAsyncWithHttpInfo(PushNotificationSearchCriteria criteria) { // verify the required parameter 'criteria' is set if (criteria == null) throw new ApiException(400, "Missing required parameter 'criteria' when calling VirtoCommercePlatformApi->PushNotificationSearch"); var localVarPath = "/api/platform/pushnotifications"; var localVarPathParams = new Dictionary<string, string>(); var localVarQueryParams = new Dictionary<string, string>(); var localVarHeaderParams = new Dictionary<string, string>(Configuration.DefaultHeader); var localVarFormParams = new Dictionary<string, string>(); var localVarFileParams = new Dictionary<string, FileParameter>(); object localVarPostBody = null; // to determine the Content-Type header string[] localVarHttpContentTypes = new string[] { "application/json", "text/json", "application/xml", "text/xml", "application/x-www-form-urlencoded" }; string localVarHttpContentType = ApiClient.SelectHeaderContentType(localVarHttpContentTypes); // to determine the Accept header string[] localVarHttpHeaderAccepts = new string[] { "application/json", "text/json", "application/xml", "text/xml" }; string localVarHttpHeaderAccept = ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts); if (localVarHttpHeaderAccept != null) localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); // set "format" to json by default // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json localVarPathParams.Add("format", "json"); if (criteria.GetType() != typeof(byte[])) { localVarPostBody = ApiClient.Serialize(criteria); // http body (model) parameter } else { localVarPostBody = criteria; // byte array } // make the HTTP request IRestResponse localVarResponse = (IRestResponse)await ApiClient.CallApiAsync(localVarPath, Method.POST, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarPathParams, localVarHttpContentType); int localVarStatusCode = (int)localVarResponse.StatusCode; if (localVarStatusCode >= 400 && (localVarStatusCode != 404 || Configuration.ThrowExceptionWhenStatusCodeIs404)) throw new ApiException(localVarStatusCode, "Error calling PushNotificationSearch: " + localVarResponse.Content, localVarResponse.Content); else if (localVarStatusCode == 0) throw new ApiException(localVarStatusCode, "Error calling PushNotificationSearch: " + localVarResponse.ErrorMessage, localVarResponse.ErrorMessage); return new ApiResponse<PushNotificationSearchResult>(localVarStatusCode, localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), (PushNotificationSearchResult)ApiClient.Deserialize(localVarResponse, typeof(PushNotificationSearchResult))); }
/// <summary> /// Search push notifications /// </summary> /// <exception cref="VirtoCommerce.Platform.Client.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="criteria">Search parameters.</param> /// <returns>Task of PushNotificationSearchResult</returns> public async System.Threading.Tasks.Task<PushNotificationSearchResult> PushNotificationSearchAsync(PushNotificationSearchCriteria criteria) { ApiResponse<PushNotificationSearchResult> localVarResponse = await PushNotificationSearchAsyncWithHttpInfo(criteria); return localVarResponse.Data; }
/// <summary> /// Search push notifications /// </summary> /// <exception cref="VirtoCommerce.Platform.Client.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="criteria">Search parameters.</param> /// <returns>PushNotificationSearchResult</returns> public PushNotificationSearchResult PushNotificationSearch(PushNotificationSearchCriteria criteria) { ApiResponse<PushNotificationSearchResult> localVarResponse = PushNotificationSearchWithHttpInfo(criteria); return localVarResponse.Data; }