コード例 #1
0
        private List <UserNotification> GetNotificationsByType(string filterOption, string userId, bool onlyUnread)
        {
            if (Enum.TryParse <UserNotificationOptionsEnum>(filterOption, out var notificationOption))
            {
                switch (notificationOption)
                {
                case UserNotificationOptionsEnum.All:
                    return(_userNotificationRepository.GetNotificationsByUserId(userId, onlyUnread).OrderByDescending(n => n.CreatedOn).ToList());

                case UserNotificationOptionsEnum.Comments:
                    return(_userNotificationRepository.GetCommentNotificationsByUserId(userId, onlyUnread).OrderByDescending(n => n.CreatedOn).ToList());

                case UserNotificationOptionsEnum.Posts:
                    return(_userNotificationRepository.GetPostNotificationsByUserId(userId, onlyUnread).OrderByDescending(n => n.CreatedOn).ToList());

                case UserNotificationOptionsEnum.DeletionRequests:
                    return(_userNotificationRepository.GetDeletionRequestNotificationsByUserId(userId, onlyUnread).OrderByDescending(n => n.CreatedOn).ToList());

                case UserNotificationOptionsEnum.DeletionResponses:
                    return(_userNotificationRepository.GetDeletionResponseNotificationsByUserId(userId, onlyUnread).OrderByDescending(n => n.CreatedOn).ToList());
                }
            }
            return(null);
        }