Beispiel #1
0
        public Models.Forum Save(Models.Forum forum)
        {
            var newForum = _databaseContext.Database.ExecuteScalar<int>("SELECT COUNT(*) FROM forumForums WHERE id=@id", new {id = forum.Id}) == 0;
            var eventArgs = new ForumEventArgs() { Forum = forum };

            if (newForum)
                Creating.Raise(this, eventArgs);
            else
                Updating.Raise(this, eventArgs);

            if (!eventArgs.Cancel)
            {
                if (newForum)
                {
                    _databaseContext.Database.Insert(forum);
                    Created.Raise(this, eventArgs);
                }
                else
                {
                    _databaseContext.Database.Update(forum);
                    Updated.Raise(this, eventArgs);
                }
                    
            }
            else
            {
                CancelledByEvent.Raise(this, eventArgs);
            }

            return forum;
        }
Beispiel #2
0
 public void Delete(Models.Forum forum)
 {
     var eventArgs = new ForumEventArgs() { Forum = forum };
     if (Deleting.RaiseAndContinue(this, eventArgs))
     {
         _databaseContext.Database.Delete(forum);
         Deleted.Raise(this, eventArgs);
     }
     else
         CancelledByEvent.Raise(this, eventArgs);
 }
Beispiel #3
0
        void ForumService_Created(object sender, ForumEventArgs e)
        {
            var content = ApplicationContext.Current.Services.ContentService.GetById(e.Forum.ParentId);

            if (content.ContentType.Alias == "Project")
            {
                var owner = content.GetValue <int>("owner");
                //NotificationsWeb.BusinessLogic.Forum.Subscribe(e.Forum.Id, owner);
                var ns = new NotificationService(ApplicationContext.Current.DatabaseContext);
                ns.SubscribeToForum(e.Forum.Id, owner);
            }
        }
Beispiel #4
0
        public void Delete(Models.Forum forum)
        {
            var eventArgs = new ForumEventArgs()
            {
                Forum = forum
            };

            if (Deleting.RaiseAndContinue(this, eventArgs))
            {
                _databaseContext.Database.Delete(forum);
                Deleted.Raise(this, eventArgs);
            }
            else
            {
                CancelledByEvent.Raise(this, eventArgs);
            }
        }
Beispiel #5
0
        public Models.Forum Save(Models.Forum forum)
        {
            var newForum  = _databaseContext.Database.ExecuteScalar <int>("SELECT COUNT(*) FROM forumForums WHERE id=@id", new { id = forum.Id }) == 0;
            var eventArgs = new ForumEventArgs()
            {
                Forum = forum
            };

            if (newForum)
            {
                Creating.Raise(this, eventArgs);
            }
            else
            {
                Updating.Raise(this, eventArgs);
            }

            if (!eventArgs.Cancel)
            {
                if (newForum)
                {
                    _databaseContext.Database.Insert(forum);
                    Created.Raise(this, eventArgs);
                }
                else
                {
                    _databaseContext.Database.Update(forum);
                    Updated.Raise(this, eventArgs);
                }
            }
            else
            {
                CancelledByEvent.Raise(this, eventArgs);
            }

            return(forum);
        }
Beispiel #6
0
        void ForumService_Deleted(object sender, ForumEventArgs e)
        {
            var ns = new NotificationService(ApplicationContext.Current.DatabaseContext);

            ns.RemoveAllForumSubscriptions(e.Forum.Id);
        }