public async Task <IEnumerable <MemberViewModel> > Get()
        {
            var users = await _userViewModelService.ListUsersWithImages();

            return(users.Where(r => r.IsActive).Select(r => new MemberViewModel
            {
                Id = r.Id,
                Email = r.Email,
                FirstName = r.FirstName,
                LastName = r.LastName,
                UserImage = r.UserImage
            }));
        }
        public async Task Should_Get_Users()
        {
            _context.Users.Add(new ApplicationUser
            {
                Email          = "*****@*****.**",
                FirstName      = "test",
                LastName       = "Test",
                CreatedAt      = DateTime.UtcNow,
                SecurityStamp  = new Guid().ToString(),
                EmailConfirmed = false,
                Id             = 1.ToString(),
                IsDeleted      = false,
                UserDetail     = new UserDetail {
                    AuthorityPercent = 1, LanguagePreference = "tr"
                }
            });

            _context.Users.Add(new ApplicationUser
            {
                Email          = "*****@*****.**",
                FirstName      = "Test",
                LastName       = "Test",
                CreatedAt      = DateTime.UtcNow,
                SecurityStamp  = new Guid().ToString(),
                EmailConfirmed = false,
                Id             = 2.ToString(),
                IsDeleted      = false,
                UserDetail     = new UserDetail {
                    AuthorityPercent = 1, LanguagePreference = "tr"
                }
            });
            _context.Roles.Add(new ApplicationRole {
                Id = 1.ToString(), Name = "Admin"
            });
            _context.UserRoles.Add(new IdentityUserRole <string> {
                RoleId = 1.ToString(), UserId = 1.ToString()
            });
            _context.SaveChanges();

            var users = await _userApiViewModelService.ListUsersWithImages();

            var admin = users.FirstOrDefault(x => x.Id == "1");

            Assert.Equal(2, users.Count);
            Assert.True(admin?.IsAdmin);
        }
Esempio n. 3
0
 public async Task <IEnumerable <UserViewModel> > Get(bool noImage = false)
 {
     return(noImage
         ? await _userViewModelService.ListUsersWithoutImages()
         : await _userViewModelService.ListUsersWithImages());
 }