public async Task <IEnumerable <IndexMessageViewModel> > AllAsync() { var messagesDTO = await userService.AllAsync(); var mapper = new MapperConfiguration(cfg => cfg.CreateMap <MessageDTO, IndexMessageViewModel>()).CreateMapper(); return(mapper.Map <IEnumerable <MessageDTO>, IEnumerable <IndexMessageViewModel> >(messagesDTO)); }