public async Task <IActionResult> GetUnreadNotificationsForCurrentUserAsync()
        {
            string currentUserId          = (await _userManager.FindByNameAsync(User.Identity.Name)).Id;
            int    currentUserInstituteId = await GetUserCurrentSelectedInstituteIdAsync();

            return(Ok(await _notificationManagementRepository.GetNotificationsForCurrentUserAsync(currentUserId, currentUserInstituteId, true)));
        }
예제 #2
0
        public async Task <IActionResult> GetLoggedInUserDetailAsync()
        {
            var user = await _userManager.FindByNameAsync(User.Identity.Name);

            if (!await _userManager.IsInRoleAsync(user, "SuperAdmin"))
            {
                var instituteId = await _instituteUserMappingHelperService.GetUserCurrentSelectedInstituteIdAsync(user.Id, true);

                var userGroups = await _iMSDbContext.UserGroupMapping.Where(x => x.UserId == user.Id && x.UserGroup.InstituteId == instituteId).Select(s => s.UserGroupId).ToListAsync();

                var permissions = await _iMSDbContext.UserGroupFeatures.Where(x => userGroups.Contains(x.UserGroupId)).ToListAsync();

                var allNotifications = await _notificationManagementRepository.GetNotificationsForCurrentUserAsync(user.Id, instituteId, false);

                bool isAdminUser = !(await _iMSDbContext.StudentBasicInformation.AnyAsync(x => x.InstituteId == instituteId && x.UserId == user.Id) ||
                                     await _iMSDbContext.StaffBasicPersonalInformation.AnyAsync(x => x.InstituteId == instituteId && x.UserId == user.Id));
                return(Ok(new { user, permissions, isAdminUser, allNotifications }));
            }
            else
            {
                return(Ok(new { user }));
            }
        }