GetAllNotifications(GetNotificationPagingRequest bundle)
        {
            var url = $"/api/Notification/paging?pageIndex=" +
                      $"{bundle.PageIndex}&pageSize={bundle.PageSize}&keyword={bundle.Keyword}&name={bundle.Name}";
            var result = await GetListAsync <GetNotification>(url);

            return(result);
        }
        public async Task <IActionResult> Index(string name, string keyword, int pageIndex = 1, int pageSize = 5)
        {
            var request = new GetNotificationPagingRequest()
            {
                Name      = name,
                Keyword   = keyword,
                PageIndex = pageIndex,
                PageSize  = pageSize
            };
            var data = await _notificationApiClient.GetAllNotifications(request);

            ViewBag.Keyword = keyword;

            return(View(data.ResultObj));
        }
Example #3
0
        GetAllNotifications(GetNotificationPagingRequest bundle)
        {
            var idrece = await _userManager.FindByNameAsync(bundle.Name);

            var notification = _context.Notifications.Include(x => x.Receiver)
                               .Where(x => x.IdReceiver == idrece.Id);

            if (!string.IsNullOrEmpty(bundle.Keyword))
            {
                notification = notification.Where(c => c.Name.Contains(bundle.Keyword.Trim()));
            }

            var countNotifi = notification;
            var totalRow    = await countNotifi.CountAsync();

            var result = await notification.Skip((bundle.PageIndex - 1) *bundle.PageSize)
                         .Take(bundle.PageSize)
                         .OrderBy(x => x.View)
                         .Select(x => new GetNotification
            {
                Id           = x.Id,
                IdReceiver   = x.IdReceiver,
                NameReceiver = x.Receiver.UserName,
                Name         = x.Name,
                Path         = x.Path,
                Time         = (DateTime.Now - x.Time).Days,
                Count        = totalRow,
                View         = x.View == true ? "Đã xem" : "Chưa xem"
            }).ToListAsync();

            var pagedResult = new PagedResult <GetNotification>()
            {
                TotalRecords = totalRow,
                PageIndex    = bundle.PageIndex,
                PageSize     = bundle.PageSize,
                Items        = result
            };

            return(new ApiSuccessResult <PagedResult <GetNotification> >(pagedResult));
        }
Example #4
0
        public async Task <IActionResult> GetAllNotifications([FromQuery] GetNotificationPagingRequest bundle)
        {
            var result = await _notificationService.GetAllNotifications(bundle);

            return(Ok(result));
        }