public void Delete_Check_Tags_Are_Cleared() { var topicRepository = Substitute.For <ITopicRepository>(); var postRepository = Substitute.For <IPostRepository>(); var membershipUserPointsService = Substitute.For <IMembershipUserPointsService>(); var settingsService = Substitute.For <ISettingsService>(); var topicService = new TopicService(membershipUserPointsService, settingsService, topicRepository, postRepository, _api, _topicNotificationService); var topic = new Topic { Name = "something", Tags = new List <TopicTag> { new TopicTag { Tag = "tagone" }, new TopicTag { Tag = "tagtwo" } } }; topicService.Delete(topic); Assert.IsTrue(!topic.Tags.Any()); }
public JsonResult Delete(long id) { if (topicStudentService.CheckTopic(id)) { return(Json("ErrorCheck", JsonRequestBehavior.AllowGet)); } return(Json(topicService.Delete(id), JsonRequestBehavior.AllowGet)); }
public void TestDelete() { mockTopicRepository.Setup(x => x.Delete(It.IsAny <string>())).Returns(true); var topicService = new TopicService(mockTopicRepository.Object); bool isDeleted = topicService.Delete("aasf65asfa44fafsf5"); Assert.IsTrue(isDeleted); }
// DELETE: api/Topic/5 public IHttpActionResult Delete(int id) { if (id <= 0) { return(BadRequest("Not a valid id")); } IService <Topic> service = new TopicService(); service.Delete(id); return(Ok()); }
public OperationResult Delete(Guid id) { var operationExecution = new OperationExecution(); Action delete = () => { var topicService = new TopicService(); topicService.Delete(id); }; return(operationExecution.ExecuteOperation(delete)); }
//api/topic public void Delete(int id) { var c = TopicService.GetById(id); if (c == null) { throw new Exception("Topic not found"); } if (!Library.Utils.IsModerator() && c.MemberId != Members.GetCurrentMemberId()) { throw new Exception("You cannot delete this topic"); } TopicService.Delete(c); }
//api/topic public void Delete(int id) { var c = TopicService.GetById(id); if (c == null) { throw new Exception("Topic not found"); } var memberShipHelper = new Umbraco.Web.Security.MembershipHelper(UmbracoContext); var currentMemberId = memberShipHelper.GetCurrentMemberId(); if (Library.Utils.IsModerator() == false && c.MemberId != currentMemberId) { throw new Exception("You cannot delete this topic"); } TopicService.Delete(c); }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; //context.Response.Write("Hello World"); //获取帖子ID int topicId = Int32.Parse(context.Request["topicId"]); //先删除回帖 ReplyService replyService = new ReplyService(); bool r = replyService.DeleteByTid(topicId); //删除主贴 TopicService topicService = new TopicService(); bool b = topicService.Delete(topicId); context.Response.Write(b); context.Response.End(); }
public void DeleteMemberPlus(int id) { if (Members.IsHq() == false) { throw new Exception("You cannot delete this member"); } var memberService = UmbracoContext.Application.Services.MemberService; var member = memberService.GetById(id); if (member == null) { throw new Exception("Member not found"); } var topicService = new TopicService(ApplicationContext.Current.DatabaseContext); var commentService = new CommentService(ApplicationContext.Current.DatabaseContext, topicService); var comments = commentService.GetAllCommentsForMember(member.Id); foreach (var comment in comments) { commentService.Delete(comment); } var topics = topicService.GetLatestTopicsForMember(member.Id, false, 100); foreach (var topic in topics) { // Only delete if this member started the topic if (topic.MemberId == member.Id) { topicService.Delete(topic); } } memberService.Delete(member); }
public async Task <ActionResult> DeleteTopic([FromRoute] int id) { await topicService.Delete(id); return(NoContent()); }