public ActionResult ProfileForumPosts(string contactId, int?page) { Guid guid; if (!Guid.TryParse(contactId, out guid)) { return(HttpNotFound()); } var context = PortalCrmConfigurationManager.CreateServiceContext(); var contact = context.CreateQuery("contact").FirstOrDefault(c => c.GetAttributeValue <Guid>("contactid") == guid); if (contact == null) { return(HttpNotFound()); } var portal = PortalCrmConfigurationManager.CreatePortalContext(); var forumDataAdapter = new WebsiteForumPostUserAggregationDataAdapter(guid, new Adxstudio.Xrm.Forums.PortalContextDataAdapterDependencies(portal)); var profileViewModel = new ProfileViewModel { ForumPostCount = forumDataAdapter.SelectPostCount(), User = contact, Website = portal.Website }; profileViewModel.ForumPosts = new PaginatedList <IForumPost>(page, profileViewModel.ForumPostCount, forumDataAdapter.SelectPostsDescending); return(View(profileViewModel)); }
public ActionResult ProfileForumPosts(string contactId, int?page) { Guid guid; if (!Guid.TryParse(contactId, out guid)) { return(HttpNotFound()); } var service = Request.GetOwinContext().GetOrganizationService(); var contact = service.RetrieveSingle(CreateContactQuery(guid)); if (contact == null) { return(HttpNotFound()); } var portal = PortalCrmConfigurationManager.CreatePortalContext(); var forumDataAdapter = new WebsiteForumPostUserAggregationDataAdapter(guid, new Adxstudio.Xrm.Forums.PortalContextDataAdapterDependencies(portal)); var profileViewModel = new ProfileViewModel { ForumPostCount = forumDataAdapter.SelectPostCount(), User = contact, Website = portal.Website }; EnityEnablePermission(profileViewModel); profileViewModel.ForumPosts = new PaginatedList <IForumPost>(page, profileViewModel.ForumPostCount, forumDataAdapter.SelectPostsDescending); return(View(profileViewModel)); }