Esempio n. 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));
        }
Esempio n. 2
0
 public ActionResult <AdministratorDTO> GetAdmin(string id)
 {
     try
     {
         AdministratorDTO user = userService.GetUser(id);
         return(Ok(user));
     }
     catch (ValidationException ex)
     {
         return(Content(ex.Message));
     }
 }