Exemplo n.º 1
0
        public GrantModershipResponse GrantModership(ISession session, GrantModershipRequest request)
        {
            var response = request.CreateResponse<GrantModershipResponse>();
            if (session.User.Role != UserRole.Admin)
            {
                //access denied
                return response;
            }

            User targetUser = null;
            using (var uow = UnitOfWorkFactory.Create())
            {
                targetUser = uow.UsersRepository.FirstMatching(UserSpecification.Id(request.TargetUserId));
                if (targetUser == null)
                {
                    //User not found
                    return response;
                }

                targetUser.RemoveModeratorship();
                uow.Commit();
            }

            response.Success = true;
            _sessionManager.SendToEachChatSessions(new ModershipGrantedInfo
                {
                    ActorName = session.User.Name,
                    TargetName = targetUser.Name,
                    TargetId = targetUser.Id,
                });

            //success
            return response;
        }
		public Task<GrantModershipResponse> GrantModership(GrantModershipRequest request)
		{
			return ConnectionManager.SendRequestAndWaitResponse<GrantModershipResponse>(request);
		}