示例#1
0
        public async Task <ActionResult <UserViewModel> > GetUser(string id)
        {
            GetUserDTO user = await userService.GetUser(id);

            var mapper = new MapperConfiguration(cfg => cfg.CreateMap <GetUserDTO, UserViewModel>()
                                                 .ForMember(p => p.RoleNames, p => p.MapFrom(s => userService.GetUserRoles(s.Id).Result.ToList()))).CreateMapper();
            UserViewModel userView = mapper.Map <GetUserDTO, UserViewModel>(user);

            return(Ok(userView));
        }