public ActionResult Index() { using (UnitOfWorkManager.NewUnitOfWork()) { // Get the favourites var favourites = _favouriteService.GetAllByMember(LoggedOnReadOnlyUser.Id); // Pull out the posts var posts = favourites.Select(x => x.Post); // Create the view Model var viewModel = new MyFavouritesViewModel(); // Map the view models // TODO - Need to improve performance of this foreach (var post in posts) { var permissions = RoleService.GetPermissions(post.Topic.Category, UsersRole); var postViewModel = ViewModelMapping.CreatePostViewModel(post, post.Votes.ToList(), permissions, post.Topic, LoggedOnReadOnlyUser, SettingsService.GetSettings(), post.Favourites.ToList()); postViewModel.ShowTopicName = true; viewModel.Posts.Add(postViewModel); } return(View(viewModel)); } }
public virtual ActionResult Index() { var loggedOnReadOnlyUser = User.GetMembershipUser(MembershipService); // Get the favourites var favourites = _favouriteService.GetAllByMember(loggedOnReadOnlyUser.Id); // Pull out the posts var posts = favourites.Select(x => x.Post); // Create the view Model var viewModel = new MyFavouritesViewModel(); // Map the view models // TODO - Need to improve performance of this foreach (var post in posts) { var permissions = RoleService.GetPermissions(post.Topic.Category, loggedOnReadOnlyUser.Roles.FirstOrDefault()); var postViewModel = ViewModelMapping.CreatePostViewModel(post, post.Votes.ToList(), permissions, post.Topic, loggedOnReadOnlyUser, SettingsService.GetSettings(), post.Favourites.ToList()); postViewModel.ShowTopicName = true; viewModel.Posts.Add(postViewModel); } return(View(viewModel)); }