public PageDto<ScheduledNotificationDto> Get(string userLogin, ScheduledNotificationFilterDto filter)
        {
            IQueryable<ScheduledNotification> query = _scheduledNotificationRepository.QueryIncluding(v => v.UserProfile);
            query = query.Where(n => n.UserProfile.UserLogin == userLogin);
            if (filter.NotificationTypes.Any())
            {
                var notofocationTypes = filter.NotificationTypes.Select(nt => nt).ToList();
                query = query.Where(n => notofocationTypes.Contains((int)n.NotificationType));
            }

            IOrderedQueryable<ScheduledNotification> orderedQuery = null;
            if (filter.OrderField == "notificationDate")
            {
                orderedQuery = filter.InvertOrder ? query.OrderByDescending(v => v.NotificationDate) : query.OrderBy(v => v.NotificationDate);
            }
            else
            {
                orderedQuery = query.OrderByDescending(v => v.NotificationDate);
            }

            var countRecords = query.Count();
            var notificationsFiltered = orderedQuery.Skip((filter.Page - 1) * filter.PageSize).Take(filter.PageSize).ToList();
            var list = notificationsFiltered.Select(item => item.ToScheduledNotificationDto()).ToList();
            return new PageDto<ScheduledNotificationDto>
            {
                TotalCount = countRecords,
                Rows = list
            };
        }
 public HttpResponseMessage Get(int page, int pageSize, string orderField, bool invertOrder, string notificationTypes)
 {
     try
     {
         var login = RequestContext.Principal.Identity.Name;
         var nTypes = notificationTypes.Trim('"');
         var filter = new ScheduledNotificationFilterDto
         {
             Page = page,
             PageSize = pageSize,
             OrderField = orderField,
             InvertOrder = invertOrder,
             NotificationTypes = !string.IsNullOrWhiteSpace(nTypes) ?
                                 nTypes.Split(',').Select(n => int.Parse(n)).ToArray() :
                                 new int[0]
         };
         var notifications = _scheduledNotificationService.Get(login, filter);
         return Request.CreateResponse(HttpStatusCode.OK, notifications);
     }
     catch (Exception ex)
     {
         return Request.CreateResponse(HttpStatusCode.BadRequest, ex.Message);
     }
 }