Ejemplo n.º 1
0
        public async Task <JsonResult> GetInboxStatistics()
        {
            int numberUnRead = 0, numberStarred = 0;
            var userId = SiteUser?.UserId ?? 0;

            if (userId <= 0)
            {
                return(Json(new { totalUnRead = numberUnRead, totalStarred = numberStarred }));
            }

            var totalUreadMess = _messageRepository.GetTotalUnreadMessages(userId);
            var inboxInfo      = await _messageRepository.GetInboxInformation(userId);

            if (inboxInfo != null && inboxInfo.Length >= 2)
            {
                numberStarred = inboxInfo[1];
            }
            if (totalUreadMess > 0)
            {
                numberUnRead = totalUreadMess;
            }

            return(Json(new { totalUnRead = numberUnRead, totalStarred = numberStarred }));
        }