Exemplo n.º 1
0
        private ForumsDetailsModel ConvertToForumDetailsModel(ForumsDetails forums)
        {
            var account = new AccountInfo();
            var accounType = typeof(AccountInfo);
            account.Department = account.GetDepartment();
            account.physicalDeliveryOfficeName = account.GetLocation();

            var forumDetails = GetForumsDetailsModel(forums);
            var subscription = ForumSubscriptionService.GetAllSubscriptions();
            var departmentForum = ForumActiveDirectoryMappingService.GetForumDepartmentMappings(accounType.GetProperty("Department").Name, account.GetDepartment());
            var locationForum = ForumActiveDirectoryMappingService.GetForumDepartmentMappings(accounType.GetProperty("physicalDeliveryOfficeName").Name, account.GetLocation());

            var nodeIsSubscribed = false;
            foreach (var subscriptionItem in subscription)
            {
                if (subscriptionItem.EmployeeName == account.GetUserName() && subscriptionItem.ForumName == forums.ForumFullPath)
                    nodeIsSubscribed = subscriptionItem.IsSubscribed;
            }
            forumDetails.IsSubscribed = nodeIsSubscribed;
            foreach (var names in departmentForum)
            {
                if (names == forums.ForumFullPath)
                    forumDetails.Department = names;
            }
            foreach (var location in locationForum)
            {
                if (location == forums.ForumFullPath)
                    forumDetails.Department = location;
            }
            forumDetails.CommentCount = forums.CommentCount;
            return forumDetails;
        }