public PartialViewResult ShowCurrentRole()
        {
            var viewModel = new UpdateRolesViewModel();

            viewModel = UserPresenter.FindUserRoleById(User.Identity.GetUserId());
            return(PartialView("CurrentRolePartialView", viewModel));
        }
        public ActionResult EditUserRole(UpdateRolesViewModel model, string command)
        {
            //var viewModel = new UpdateRolesViewModel();
            if (command.Equals("Save Change"))
            {
                return(RedirectToAction("Index"));
            }

            if (ModelState.IsValid)
            {
                if (command.Equals("Add"))
                {
                    if (!UserPresenter.IsRoleExist(model.UserRoles))
                    {
                        UserPresenter.CreateRole(model.UserRoles);
                    }
                    UserPresenter.AddRole(User.Identity.GetUserId(), model.UserRoles);
                }
                if (command.Equals("Remove"))
                {
                    if (UserPresenter.IsRoleExist(model.UserRoles))
                    {
                        UserPresenter.RemoveRole(User.Identity.GetUserId(), model.UserRoles);
                    }
                }

                //viewModel = UserPresenter.FindUserRoleById(User.Identity.GetUserId());
                return(View());
            }
            //viewModel = UserPresenter.FindUserRoleById(User.Identity.GetUserId());
            return(View());
        }
        public UpdateRolesViewModel FindUserRoleById(string UserId)
        {
            var currentUserRole = UserManager.FindById(UserId);

            if (currentUserRole == null)
            {
                throw new UserNotFoundException();
            }
            UpdateRolesViewModel model = new UpdateRolesViewModel {
                UserRoles = String.Join(", ", UserManager.GetRoles(UserId))
            };

            return(model);
        }
        public UpdateRolesViewModel GetRolesViewModel(string participantId)
        {
            var result = new UpdateRolesViewModel
            {
                ParticipantId = participantId
            };

            var engagement = Session.Query <ConventionEngagement>()
                             .SingleOrDefault(x => x.ParticipantId == participantId &&
                                              x.ConventionId == Actor.ManagedConvention.ConventionId);
            var roles = engagement != null ? engagement.Roles : new List <ConventionRoles>();

            if (participantId.StartsWith("LongTerm"))
            {
                var longTerm = Session.Load <LongTermParticipant>(participantId);
                if (longTerm != null)
                {
                    result.IsLongTerm      = true;
                    result.ParticipantName = longTerm.FullName;
                    result.SystemRoles     = longTerm.SystemRoles;
                    result.ConventionRoles = roles;
                    return(result);
                }
            }

            if (participantId.StartsWith("ShortTerm"))
            {
                var shortTerm = Session.Load <ShortTermParticipant>(participantId);

                if (shortTerm != null)
                {
                    result.IsLongTerm      = false;
                    result.ParticipantName = shortTerm.FullName;
                    result.ConventionRoles = roles;
                    return(result);
                }
            }


            throw new Exception("Unknown Me Term or Me not found");
        }