Ejemplo n.º 1
0
 public void Post(TopicSaveModel model)
 {
     var t = new Topic();
     t.Body = model.Body;
     t.MemberId = Members.GetCurrentMemberId();
     t.Created = DateTime.Now;
     t.ParentId = model.Forum;
     TopicService.Save(t);
 }
Ejemplo n.º 2
0
        public void Put(int id, TopicSaveModel model)
        {
            var c = TopicService.GetById(id);

            if (c == null)
                throw new Exception("Topic not found");

            if (c.MemberId != Members.GetCurrentMemberId())
                throw new Exception("You cannot edit this topic");

            c.Body = model.Body;
            TopicService.Save(c);
        }
Ejemplo n.º 3
0
        public ExpandoObject Topic(int id, TopicSaveModel model)
        {
            dynamic o = new ExpandoObject();

            var t = TopicService.GetById(id);

            if (t == null)
                throw new Exception("Topic not found");

            if (t.MemberId != Members.GetCurrentMemberId() && Members.IsAdmin() == false)
                throw new Exception("You cannot edit this topic");

            t.Updated = DateTime.Now;
            t.Body = model.Body;
            t.Version = model.Version;
            t.ParentId = model.Forum;
            t.Title = model.Title;
            TopicService.Save(t);

            o.url = string.Format("{0}/{1}-{2}", library.NiceUrl(t.ParentId), t.Id, t.UrlName);

            return o;
        }
Ejemplo n.º 4
0
        public ExpandoObject Topic(TopicSaveModel model)
        {
            dynamic o = new ExpandoObject();

            var t = new Topic();
            t.Body = model.Body;
            t.Title = model.Title;
            t.MemberId = Members.GetCurrentMemberId();
            t.Created = DateTime.Now;
            t.ParentId = model.Forum;
            t.UrlName = url.FormatUrl(model.Title);
            t.Updated = DateTime.Now;
            t.Version = model.Version;
            t.Locked = false;
            t.LatestComment = 0;
            t.LatestReplyAuthor = 0;
            t.Replies = 0;
            t.Score = 0;
            t.Answer = 0;
            t.LatestComment = 0;
            t.IsSpam = Members.GetCurrentMember().GetPropertyValue<bool>("blocked") || t.DetectSpam();
            TopicService.Save(t);

            if (t.IsSpam)
                SpamChecker.SendSlackSpamReport(t.Body, t.Id, "topic", t.MemberId);

            o.url = string.Format("{0}/{1}-{2}", library.NiceUrl(t.ParentId), t.Id, t.UrlName);

            return o;
        }