Beispiel #1
0
        public IQueryable <NotificationDto> GetNotifications()
        {
            var userId            = User.Identity.GetUserId();
            var userNotifications = _userNotificationService
                                    .GetAll()
                                    .Where(n => n.UserId == userId && !n.IsRead)
                                    .Select(n => n.Notification)
                                    .AsQueryable()
                                    .ProjectTo <NotificationDto>();

            return(userNotifications);
        }
Beispiel #2
0
 public ActionResult <IEnumerable <UserNotification> > GetUserNotifications()
 {
     try
     {
         List <UserNotificationVM> result = new List <UserNotificationVM>();
         var data = _userNotificationService.GetAll();
         foreach (var item in data)
         {
             result.Add(_mapper.Map <UserNotificationVM>(item));
         }
         return(Ok(result));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }