public ActionResult <IEnumerable <BookViewModel> > Get() { var user = GetUser(); var userId = GetToken(); if (user == null) { _userRepository.CreateDefaultUser(userId); user = _userRepository.FindOne(userId); } var userVm = UserRepositoryHelper.Map(user); return(Ok(userVm.Books)); }
public ActionResult <IEnumerable <UserViewModel> > Get() { try { var users = _userRepository.GetAllUsers(); var userVms = users.Select((user, index) => { return(UserRepositoryHelper.Map(user)); }).ToList(); return(Ok(userVms)); } catch (Exception ex) { return(BadRequest(ex)); } }