コード例 #1
0
        public async Task <bool> RestoreByIdAsync(string id)
        {
            var video = await videoRepository.AllWithDeleted()
                        .Include(v => v.Comments)
                        .Include(v => v.Ratings)
                        .SingleOrDefaultAsync(v => v.Id == id);

            if (video == null)
            {
                return(false);
            }
            foreach (var rate in video.Ratings)
            {
                await rateService.RestoreByIdAsync(rate.Id);
            }
            foreach (var comment in video.Comments)
            {
                await commentSerivce.RestoreByIdAsync(comment.Id);
            }

            videoRepository.Undelete(video);
            var result = await videoRepository.SaveChangesAsync();

            return(result > 0);
        }
コード例 #2
0
        public async Task <bool> UnbanByIdAsync(string id)
        {
            var user = await userRepository.AllWithDeleted()
                       .Include(u => u.Uploads)
                       .Include(u => u.Ratings)
                       .Include(u => u.Comments)
                       .SingleOrDefaultAsync(u => u.Id == id);

            if (user == null)
            {
                return(false);
            }
            foreach (var rate in user.Ratings)
            {
                await rateService.RestoreByIdAsync(rate.Id);
            }
            foreach (var comment in user.Comments)
            {
                await commentSerivce.RestoreByIdAsync(comment.Id);
            }
            foreach (var video in user.Uploads)
            {
                await videoService.RestoreByIdAsync(video.Id);
            }
            userRepository.Undelete(user);


            await userRepository.SaveChangesAsync();


            return(true);
        }
コード例 #3
0
        public async Task <bool> RestoreByIdAsync(string id)
        {
            var comment = await repository.AllWithDeleted().SingleOrDefaultAsync(c => c.Id == id);

            if (comment == null)
            {
                return(false);
            }
            repository.Undelete(comment);
            var result = await repository.SaveChangesAsync();

            return(result > 0);
        }
コード例 #4
0
        public async Task <bool> RestoreByIdAsync(string id)
        {
            if (id == null)
            {
                return(false);
            }
            var rate = await repository.AllWithDeleted().SingleOrDefaultAsync(r => r.Id == id);

            if (rate == null)
            {
                return(false);
            }
            repository.Undelete(rate);
            var result = await repository.SaveChangesAsync();

            return(result > 0);
        }
コード例 #5
0
        public async Task ChangeIsDelete(string email)
        {
            var user = _usersRepository.AllWithDeleted().FirstOrDefault(u => u.Email == email);

            if (user != null)
            {
                if (user.IsDeleted)
                {
                    _usersRepository.Undelete(user);
                }
                else
                {
                    _usersRepository.Delete(user);
                }

                await _usersRepository.SaveChangesAsync();
            }
        }