Пример #1
0
        public ActionResult DeleteConfirmed(int id)
        {
            if (!Services.Permissions.Authorize(StandardPermissionProvider.ManageTopics))
            {
                return(AccessDeniedView());
            }

            var topic = _topicService.GetTopicById(id);

            if (topic == null)
            {
                return(HttpNotFound());
            }

            if (topic.IsSystemTopic)
            {
                NotifyError(T("Admin.ContentManagement.Topics.CannotBeDeleted"));
                return(RedirectToAction("Edit", new { id = topic.Id }));
            }

            _topicService.DeleteTopic(topic);

            NotifySuccess(T("Admin.ContentManagement.Topics.Deleted"));
            return(RedirectToAction("List"));
        }
        public virtual async Task DeleteTopic(Topic topic)
        {
            await _topicService.DeleteTopic(topic);

            //activity log
            await _customerActivityService.InsertActivity("DeleteTopic", topic.Id, _localizationService.GetResource("ActivityLog.DeleteTopic"), topic.Title ?? topic.SystemName);
        }
Пример #3
0
        public virtual IActionResult Delete(int id)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageTopics))
            {
                return(AccessDeniedView());
            }

            //try to get a topic with the specified id
            var topic = _topicService.GetTopicById(id);

            if (topic == null)
            {
                return(RedirectToAction("List"));
            }

            _topicService.DeleteTopic(topic);

            SuccessNotification(_localizationService.GetResource("Admin.ContentManagement.Topics.Deleted"));

            //activity log
            _customerActivityService.InsertActivity("DeleteTopic",
                                                    string.Format(_localizationService.GetResource("ActivityLog.DeleteTopic"), topic.Title ?? topic.SystemName), topic);

            return(RedirectToAction("List"));
        }
Пример #4
0
        public async Task <Either <ActionResult, Unit> > DeleteTheme(Guid themeId)
        {
            return(await _userService.CheckCanManageAllTaxonomy()
                   .OnSuccess(
                       () => _persistenceHelper.CheckEntityExists <Theme>(
                           themeId,
                           q => q.Include(t => t.Topics)
                           )
                       )
                   .OnSuccessVoid(
                       async theme =>
            {
                // For now we only want to delete test themes as we
                // don't really have a mechanism to clean things up
                // properly across the entire application.
                // TODO: EES-1295 ability to completely delete releases
                if (!theme.Title.StartsWith("UI test theme"))
                {
                    return;
                }

                var topicIds = theme.Topics.Select(topic => topic.Id).ToList();

                foreach (var topicId in topicIds)
                {
                    await _topicService.DeleteTopic(topicId);
                }

                _context.Themes.Remove(theme);
                await _context.SaveChangesAsync();

                await _publishingService.TaxonomyChanged();
            }
                       ));
        }
Пример #5
0
        public ActionResult DeleteConfirmed(int id)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageTopics))
            {
                return(AccessDeniedView());
            }

            var topic = _topicService.GetTopicById(id);

            if (topic == null)
            {
                return(RedirectToAction("List"));
            }

            if (topic.IsSystemTopic)
            {
                NotifyError(_localizationService.GetResource("Admin.ContentManagement.Topics.CannotBeDeleted"));
                return(RedirectToAction("List"));
            }

            _topicService.DeleteTopic(topic);

            NotifySuccess(_localizationService.GetResource("Admin.ContentManagement.Topics.Deleted"));
            return(RedirectToAction("List"));
        }
Пример #6
0
 public void Delete(Post post, User user)
 {
     if (user.UserID == post.UserID || user.IsInRole(PermanentRoles.Moderator))
     {
         var topic = _topicService.Get(post.TopicID);
         var forum = _forumService.Get(topic.ForumID);
         if (post.IsFirstInTopic)
         {
             _topicService.DeleteTopic(topic, user);
         }
         else
         {
             _moderationLogService.LogPost(user, ModerationType.PostDelete, post, String.Empty, String.Empty);
             post.IsDeleted    = true;
             post.LastEditTime = DateTime.UtcNow;
             post.LastEditName = user.Name;
             post.IsEdited     = true;
             _postRepository.Update(post);
             _topicService.RecalculateReplyCount(topic);
             _topicService.UpdateLast(topic);
             _forumService.UpdateCounts(forum);
             _forumService.UpdateLast(forum);
         }
     }
     else
     {
         throw new InvalidOperationException("User must be Moderator or author to delete post.");
     }
 }
Пример #7
0
        public JsonResult Delete(long id)
        {
            Result result = new Result();

            _iTopicService.DeleteTopic(id);
            result.success = true;
            return(Json(result));
        }
Пример #8
0
        public ActionResult Delete(int id)
        {
            var sectionIdForReidirect = _topicService.GetSectionIdBTopicId(id);

            _topicService.DeleteTopic(id);

            return(RedirectToAction("Item", "Section", new { Id = sectionIdForReidirect }));
        }
Пример #9
0
        protected void btnDeleteTopic_Click(object sender, EventArgs e)
        {
            var topicId = int.Parse(topicID.Value);

            _topicService.DeleteTopic(topicId);

            loadReportedTopics();
        }
Пример #10
0
        public async Task Delete_RepositoryInvokes()
        {
            //Act
            await _topicService.DeleteTopic(It.IsAny <Guid>());

            //Assert
            _topicRepositoryMock.Verify(r => r.Delete(It.IsAny <Guid>()));
            _unitOfWorkMock.Verify(uow => uow.Topics);
        }
Пример #11
0
        public async Task <ActionResult <TopicModel> > DeleteTopic(int id)
        {
            try
            {
                await _topicService.DeleteTopic(id).ConfigureAwait(false);
            }
            catch (ArgumentException ex)
            {
                NotFound(ex.Message);
            }

            return(Ok());
        }
Пример #12
0
        public ActionResult DeleteConfirmed(int id)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageTopics))
            {
                return(AccessDeniedView());
            }

            var topic = _topicService.GetTopicById(id);

            _topicService.DeleteTopic(topic);

            SuccessNotification(_localizationService.GetResource("Admin.ContentManagement.Topics.Deleted"));
            return(RedirectToAction("List"));
        }
Пример #13
0
        public async Task <IActionResult> DeleteTopic(Guid id)
        {
            try
            {
                await _workWithTopic.DeleteTopic(id);

                return(Ok());
            }
            catch (ArgumentException ex)
            {
                return(NotFound(ex.Message));
            }
            catch (Exception ex)
            {
                return(Problem(ex.Message));
            }
        }
        public IActionResult Delete(int topicId)
        {
            // retrieve the topic from the Database
            var topic = _topicService.GetTopic(topicId);

            if (topic == null)
            {
                return(NotFound(new
                {
                    Error = String.Format("Topic ID {0} has not been found", topicId)
                }));
            }

            // Call the domain layer to handle the delete
            _topicService.DeleteTopic(topic);

            // return an HTTP Status 200 (OK).
            return(new NoContentResult());
        }
Пример #15
0
        public async Task <StandardResponse> DeleteTopic(ClaimsPrincipal identity, TopicDeleteViewModel model, ModelStateDictionary modelState)
        {
            if (!modelState.IsValid)
            {
                return(modelState.StandardError());
            }

            using (var db = new ServiceDb())
            {
                using (var user = await _userService.Become(db, identity))
                {
                    await _topicService.DeleteTopic(db, user, model.TopicId, model.RowVersion);

                    await db.SaveChangesAsync();

                    return(StandardResponse.ForSuccess());
                }
            }
        }
Пример #16
0
        public ActionResult DeleteConfirmed(int id)
        {
            var topic = _topicService.GetTopicById(id);

            if (topic == null)
            {
                return(HttpNotFound());
            }

            if (topic.IsSystemTopic)
            {
                NotifyError(T("Admin.ContentManagement.Topics.CannotBeDeleted"));
                return(RedirectToAction("Edit", new { id = topic.Id }));
            }

            _topicService.DeleteTopic(topic);

            NotifySuccess(T("Admin.ContentManagement.Topics.Deleted"));
            return(RedirectToAction("List"));
        }
Пример #17
0
        public virtual IActionResult Delete(int id)
        {
            //try to get a topic with the specified id
            Topic topic = _topicService.GetTopicById(id);

            if (topic == null)
            {
                return(RedirectToAction("List"));
            }

            _topicService.DeleteTopic(topic);

            SuccessNotification("İçerik Sİlindi");

            //activity log
            _customerActivityService.InsertActivity("DeleteTopic",
                                                    string.Format("DeleteTopic{0}", topic.Title ?? topic.SystemName), topic);

            return(RedirectToAction("List"));
        }
        public RedirectToRouteResult ToggleDeleted(int id)
        {
            var topic = _topicService.Get(id);

            if (topic == null)
            {
                throw new Exception(String.Format("Topic with ID {0} not found. Can't delete/undelete.", id));
            }
            var user = this.CurrentUser();

            if (topic.IsDeleted)
            {
                _topicService.UndeleteTopic(topic, user);
            }
            else
            {
                _topicService.DeleteTopic(topic, user);
            }
            return(RedirectToAction("Topic", "Forum", new { id = topic.UrlName }));
        }
Пример #19
0
        public async Task <RedirectToActionResult> ToggleDeleted(int id)
        {
            var topic = await _topicService.Get(id);

            if (topic == null)
            {
                throw new Exception($"Topic with ID {id} not found. Can't delete/undelete.");
            }
            var user = _userRetrievalShim.GetUser();

            if (topic.IsDeleted)
            {
                await _topicService.UndeleteTopic(topic, user);
            }
            else
            {
                await _topicService.DeleteTopic(topic, user);
            }
            return(RedirectToAction("Topic", "Forum", new { id = topic.UrlName }));
        }
Пример #20
0
        public async Task <IActionResult> Delete([FromRoute] string id)
        {
            var logger = new LoggerConfiguration()
                         .WriteTo.Sentry(_configuration.GetConnectionString("SENTRY"))
                         .WriteTo.Console()
                         .Enrich.FromLogContext()
                         .CreateLogger();

            try
            {
                logger.Information("Запрос на удаление темы");
                await _topicService.DeleteTopic(int.Parse(id));

                return(StatusCode(StatusCodes.Status200OK));
            }
            catch (Exception e)
            {
                logger.Error(e, "Произошла ошибка");
                return(StatusCode(StatusCodes.Status500InternalServerError, "Произошла ошибка, обратитесь в службу поддержки!"));
            }
        }
Пример #21
0
        public async Task Delete(Post post, User user)
        {
            if (user.UserID == post.UserID || user.IsInRole(PermanentRoles.Moderator))
            {
                var topic = await _topicService.Get(post.TopicID);

                var forum = await _forumService.Get(topic.ForumID);

                if (post.IsFirstInTopic)
                {
                    await _topicService.DeleteTopic(topic, user);
                }
                else
                {
                    await _moderationLogService.LogPost(user, ModerationType.PostDelete, post, String.Empty, String.Empty);

                    post.IsDeleted    = true;
                    post.LastEditTime = DateTime.UtcNow;
                    post.LastEditName = user.Name;
                    post.IsEdited     = true;
                    await _postRepository.Update(post);

                    await _topicService.RecalculateReplyCount(topic);

                    await _topicService.UpdateLast(topic);

                    _forumService.UpdateCounts(forum);
                    await _forumService.UpdateLast(forum);

                    await _searchIndexQueueRepository.Enqueue(new SearchIndexPayload { TenantID = _tenantService.GetTenant(), TopicID = topic.TopicID });
                }
            }
            else
            {
                throw new InvalidOperationException("User must be Moderator or author to delete post.");
            }
        }
Пример #22
0
        public ActionResult Delete(Guid id, TopicModel topic)
        {
            if (id == topic.Id)
            {
                try
                {
                    service.DeleteTopic(topic);
                    return(RedirectToAction("Index"));
                }
                catch (UpdateException)
                {
                    topic = service.GetTopic(id);
                    ViewData.Add(new KeyValuePair <string, object>(ViewRes.Topic.Erro + ':', ViewRes.Topic.UpdateException));
                }
                catch (Exception e)
                {
                    topic = service.GetTopic(id);
                    ModelState.AddModelError("", e.Message);
                    ViewData.Add(new KeyValuePair <string, object>(ViewRes.Topic.Erro + ':', ViewRes.Topic.UpdateException));
                }
            }

            return(View(topic));
        }
Пример #23
0
        public async Task <ActionResult <int> > DeleteTopic(int id)
        {
            var rs = await _topicService.DeleteTopic(id);

            return(Ok(rs));
        }
Пример #24
0
 public void Delete(int id)
 {
     _service.DeleteTopic(id);
 }
Пример #25
0
 public IActionResult DeleteTopic(int id)
 {
     _topicService.DeleteTopic(id);
     return(RedirectToAction("Index", "Home"));
 }
Пример #26
0
 public async Task <ActionResult> DeleteTopic(Guid topicId)
 {
     return(await _topicService
            .DeleteTopic(topicId)
            .HandleFailuresOrNoContent());
 }
Пример #27
0
 public async Task <IActionResult> DeleteTopic(int id)
 {
     return(await Do(async() => await _topicService.DeleteTopic(User.Identity.GetUserId(), id)));
 }
Пример #28
0
        // DELETE api/<controller>/5
        public void Delete(int id)
        {
            var sectionIdForReidirect = _topicService.GetSectionIdBTopicId(id);

            _topicService.DeleteTopic(id);
        }
Пример #29
0
 public ActionResult DeletTopic(CreateEditTopicModel topic)
 {
     topicService.DeleteTopic(topic.Id);
     return(RedirectToAction("Topics"));
 }
Пример #30
0
 /// <summary>
 /// Deletes a topic
 /// </summary>
 /// <param name="topic">Topic</param>
 public void DeleteTopic([FromBody] Topic topic)
 {
     _topicService.DeleteTopic(topic);
 }