Пример #1
0
        public ThreadPartHandler(IRepository<ThreadPartRecord> repository, 
            IPostService postService,
            IThreadService threadService,
            IForumService forumService,
            IContentManager contentManager) {
            _postService = postService;
            _threadService = threadService;
            _forumService = forumService;
            _contentManager = contentManager;

            Filters.Add(StorageFilter.For(repository));

            OnGetDisplayShape<ThreadPart>(SetModelProperties);
            OnGetEditorShape<ThreadPart>(SetModelProperties);
            OnUpdateEditorShape<ThreadPart>(SetModelProperties);

            OnActivated<ThreadPart>(PropertyHandlers);
            OnLoading<ThreadPart>((context, part) => LazyLoadHandlers(part));
            OnCreated<ThreadPart>((context, part) => UpdateForumPartCounters(part));
            OnPublished<ThreadPart>((context, part) => UpdateForumPartCounters(part));
            OnUnpublished<ThreadPart>((context, part) => UpdateForumPartCounters(part));
            OnVersioning<ThreadPart>((context, part, newVersionPart) => LazyLoadHandlers(newVersionPart));
            OnVersioned<ThreadPart>((context, part, newVersionPart) => UpdateForumPartCounters(newVersionPart));
            OnRemoved<ThreadPart>((context, part) => UpdateForumPartCounters(part));
            
            OnRemoved<ForumPart>((context, b) =>
                _threadService.Delete(context.ContentItem.As<ForumPart>()));
        }
Пример #2
0
        public ThreadPartHandler(IRepository <ThreadPartRecord> repository,
                                 IPostService postService,
                                 IThreadService threadService,
                                 IForumService forumService,
                                 IContentManager contentManager)
        {
            _postService    = postService;
            _threadService  = threadService;
            _forumService   = forumService;
            _contentManager = contentManager;

            Filters.Add(StorageFilter.For(repository));

            OnGetDisplayShape <ThreadPart>(SetModelProperties);
            OnGetEditorShape <ThreadPart>(SetModelProperties);
            OnUpdateEditorShape <ThreadPart>(SetModelProperties);

            OnActivated <ThreadPart>(PropertyHandlers);
            OnLoading <ThreadPart>((context, part) => LazyLoadHandlers(part));
            OnCreated <ThreadPart>((context, part) => UpdateForumPartCounters(part));
            OnPublished <ThreadPart>((context, part) => UpdateForumPartCounters(part));
            OnUnpublished <ThreadPart>((context, part) => UpdateForumPartCounters(part));
            OnVersioning <ThreadPart>((context, part, newVersionPart) => LazyLoadHandlers(newVersionPart));
            OnVersioned <ThreadPart>((context, part, newVersionPart) => UpdateForumPartCounters(newVersionPart));
            OnRemoved <ThreadPart>((context, part) => UpdateForumPartCounters(part));

            OnRemoved <ForumPart>((context, b) =>
                                  _threadService.Delete(context.ContentItem.As <ForumPart>()));
        }
Пример #3
0
        public void DeleteThread_ShouldCallRestDeleteEndpoint()
        {
            // Arrange
            _target = new ThreadService(_threadApiServiceMock.Object);

            // Act
            _target.Delete(1).Subscribe();

            // Assert
            _threadApiMock.Verify(x => x.DeleteThread(1), Times.Once);
        }
Пример #4
0
        public void Delete_ShouldCallRepositoryDelete()
        {
            // Arrange
            var id = 1;

            _threadRepositoryMock
            .Setup(x => x.Delete(id));

            // Act
            _threadService.Delete(id);

            // Assert
            _threadRepositoryMock.Verify(x => x.Delete(id), Times.Once);
        }
Пример #5
0
        public int DeleteThread(string thread_id, [FromQuery] string business_id, [FromQuery] string access_token)
        {
            int count = 0;

            if (access_token != "@bazavietnam")
            {
                return(count);
            }
            if (!string.IsNullOrWhiteSpace(business_id) && !string.IsNullOrWhiteSpace(thread_id))
            {
                count = _threadService.Delete(business_id, thread_id);
            }
            return(count);
        }
Пример #6
0
        public ThreadPartHandler(IRepository<ThreadPartRecord> repository, 
            IPostService postService,
            IThreadService threadService,
            IContentManager contentManager,
            ICountersService countersService,
            ISubscriptionService subscriptionService,
            IOrchardServices orchardServices
            
            ) {
            _postService = postService;
            _threadService = threadService;
            _contentManager = contentManager;
            _countersService = countersService;
            _subscriptionService = subscriptionService;
            _orchardServices = orchardServices;

            Filters.Add(StorageFilter.For(repository));

            OnGetDisplayShape<ThreadPart>(SetModelProperties);
            OnGetEditorShape<ThreadPart>(SetModelProperties);
            OnUpdateEditorShape<ThreadPart>(SetModelProperties);

            OnActivated<ThreadPart>(PropertyHandlers);
            OnLoading<ThreadPart>((context, part) => LazyLoadHandlers(part));

            OnCreated<ThreadPart>((context, part) => { 
                _countersService.UpdateForumPartCounters(part);
                //bit expensive but doesn't happen frequently
                part.ForumsHomepageId = part.ForumPart.ForumCategoryPart.ForumsHomePagePart.Id;   
            });

            OnPublished<ThreadPart>((context, part) => {
                _countersService.UpdateForumPartCounters(part);
                part.LastestValidPostDate = DateTime.UtcNow;
                //bit expensive but doesn't happen frequently
                part.ForumsHomepageId = part.ForumPart.ForumCategoryPart.ForumsHomePagePart.Id;              
            });

            OnUnpublished<ThreadPart>((context, part) => _countersService.UpdateForumPartCounters(part));
            OnVersioning<ThreadPart>((context, part, newVersionPart) => LazyLoadHandlers(newVersionPart));
            OnVersioned<ThreadPart>((context, part, newVersionPart) => _countersService.UpdateForumPartCounters(newVersionPart));
            OnRemoved<ThreadPart>((context, part) => OnThreadRemoved(context, part));
            
            OnRemoved<ForumPart>((context, b) =>
                _threadService.Delete(context.ContentItem.As<ForumPart>(), true));
        }
Пример #7
0
        public async Task <ActionResult> Delete(int id)
        {
            var currentUser = await GettingCurrentClient();

            var threadToDelete = await _threadsService.Get(id);

            if (threadToDelete == null)
            {
                return(NotFound($"Couldn't find a thread with the id of {id} to delete"));
            }

            if (currentUser.Id != threadToDelete.Author.Id)
            {
                if (currentUser.Role != Role.Admin)
                {
                    return(Forbid());
                }
            }

            await _threadsService.Delete(id);

            return(NoContent());
        }
Пример #8
0
 public void Delete(string id)
 {
     _threadService.Delete(id);
 }
Пример #9
0
 public IActionResult Delete(int id)
 {
     _threadService.Delete(id);
     return(Ok());
 }