Beispiel #1
0
        public ActionResult ViewUserGroups()
        {
            int userId = RetrieveUserId();

            if (0 != userId)
            {
                var groups     = new GroupManager().RetrieveUserGroups(userId);
                var groupsView = new List <UserGroupViewModel>(groups.Count());

                foreach (Group group in groups)
                {
                    groupsView.Add(new UserGroupViewModel()
                    {
                        GroupId
                            = group.GroupID,
                        Name
                            = group.Name,
                        LeaderUserName
                            = group.GroupLeader.User.UserName,
                        LeaderEmail
                            = group.GroupLeader.User.EmailAddress,
                        CreatedDate
                            = group.CreatedDate
                    });
                }

                return(View(groupsView));
            }

            return(View("Error"));
        }
        // GET: Group
        /// <summary>
        /// Created by: Trent Cullinan 03/31/2016
        /// Displays list of groups a User belongs to
        ///
        /// Modified by: Nicholas King 04/03/2016
        /// Merged grouplist display and create group
        /// added join group list table
        ///
        /// </summary>
        /// <returns></returns>
        public ActionResult Index()
        {
            GroupIndexViewModel model = new GroupIndexViewModel();
            int userId = RetrieveUserId();

            if (0 != userId)
            {
                var groups = new GroupManager().GetUserGroups(userId);
                model.UserGroupList = new List <GroupIndexViewModel.UserGroupViewModel>(groups.Count());

                foreach (Group group in groups)
                {
                    model.UserGroupList.Add(new GroupIndexViewModel.UserGroupViewModel()
                    {
                        GroupId
                            = group.GroupID,
                        Name
                            = group.Name,
                        LeaderUserName
                            = group.GroupLeader.User.UserName,
                        LeaderEmail
                            = group.GroupLeader.User.EmailAddress,
                        CreatedDate
                            = group.CreatedDate
                    });
                }

                var joinableGroups = new GroupManager().GetGroupsToJoin(userId);
                model.NonUserGroupList = new List <GroupIndexViewModel.UserGroupViewModel>(joinableGroups.Count());

                foreach (Group group in joinableGroups)
                {
                    if (WebConfigurationManager.AppSettings["ExpertGroup"] != group.Name)
                    {
                        model.NonUserGroupList.Add(new GroupIndexViewModel.UserGroupViewModel()
                        {
                            GroupId
                                = group.GroupID,
                            Name
                                = group.Name,
                            LeaderUserName
                                = group.GroupLeader.User.UserName,
                            LeaderEmail
                                = group.GroupLeader.User.EmailAddress,
                            CreatedDate
                                = group.CreatedDate
                        });
                    }
                }


                return(View(model));
            }

            return(View("Error"));
        }