示例#1
0
        public List <UserDTO> GetAll()
        {
            var users = _context.ApplicationUsers
                        .Include(ur => ur.UserRoles)
                        .ThenInclude(r => r.Role)
                        .Include(a => a.Affiliate)
                        .Select(x => UserMapper.ApplicationUserToDTO(x))
                        .ToList();

            return(users);
        }
示例#2
0
        public List <UserDTO> GetAffiliateUsers(int affiliateId)
        {
            var users = _context.ApplicationUsers
                        .Include(ur => ur.UserRoles)
                        .ThenInclude(r => r.Role)
                        .Where(u => u.AffiliateId.Equals(affiliateId))
                        .Select(x => UserMapper.ApplicationUserToDTO(x))
                        .ToList();

            return(users);
        }
示例#3
0
        public UserDTO GetByUsername(string username)
        {
            var applicationUser = _context.ApplicationUsers
                                  .Include(ur => ur.UserRoles)
                                  .ThenInclude(r => r.Role)
                                  .Include(a => a.Affiliate)
                                  .SingleOrDefault(x => x.UserName.Equals(username));

            if (applicationUser == null)
            {
                return(null);
            }

            return(UserMapper.ApplicationUserToDTO(applicationUser));
        }
示例#4
0
        public UserDTO GetCurrent()
        {
            var applicationUser = _context.ApplicationUsers
                                  .Include(ur => ur.UserRoles)
                                  .ThenInclude(r => r.Role)
                                  .Include(a => a.Affiliate)
                                  .SingleOrDefault(x => x.Id.Equals(_userProviderService.GetUserId()));

            if (applicationUser == null)
            {
                return(null);
            }

            return(UserMapper.ApplicationUserToDTO(applicationUser));
        }