Exemplo n.º 1
0
        public void DeleteUser(int userId)
        {
            Model.Entity.User user = _userRepository.Get(u => u.UserID == userId);
            if (user != null)
            {
                //Remove posts
                var posts = _postService.PostsByUserId(userId);
                posts.ForEach(post => _postService.DeletePost(post.PostID));

                //Delete all referral created by user
                _referralService.DeleteReferrals(userId);

                //Delete user role mapping
                _userRoleMappingRepository.Delete(rm => rm.UserID == userId);

                //Now Delete user object
                _userRepository.Delete(u => u.UserID == userId);
                _unitOfWork.Commit();
            }
        }