//void EnsureNonNullDiscussion()
        //{
        //    if (EditedDiscussion == null)
        //        btnAddDiscussion_Click(null,null);
        //}

        private void btnRemove_Click(object sender, RoutedEventArgs e)
        {
            if (EditedDiscussion != null && Ctors.DiscussionExists(EditedDiscussion))
            {
                BusyWndSingleton.Show("Deleting discussion...");
                try
                {
                    if (SessionInfo.Get().discussion != null)
                    {
                        if (SessionInfo.Get().discussion.Id == EditedDiscussion.Id)
                        {
                            SessionInfo.Get().discussion = null;
                        }
                    }

                    DaoUtils.DeleteDiscussion(EditedDiscussion);
                    discussionSelector.Set(PublicBoardCtx.Get().Discussion, "Subject");
                    EditedDiscussion = null;
                }
                finally
                {
                    BusyWndSingleton.Hide();
                }
            }
        }
        private void SaveDiscussion()
        {
            if (EditedDiscussion == null)
            {
                return;
            }

            SaveParticipants();

            if (!Ctors.DiscussionExists(EditedDiscussion))
            {
                PublicBoardCtx.Get().AddToDiscussion(EditedDiscussion);
            }

            background.SaveChanges();

            PublicBoardCtx.Get().SaveChanges();
        }
Beispiel #3
0
        public static void DeleteDiscussion(Discussion d)
        {
            if (!Ctors.DiscussionExists(d))
            {
                return;
            }

            var ctx = PublicBoardCtx.Get();

            //delete attachments
            var attachments = new List <Attachment>();

            foreach (var a in d.Attachment)
            {
                attachments.Add(a);
            }
            foreach (var a in attachments)
            {
                ctx.DeleteObject(a);
            }

            //delete background
            if (d.Background != null)
            {
                d.Background = null;
            }

            foreach (var t in d.Topic)
            {
                t.Person.Clear();
                t.ArgPoint.Clear();
            }
            d.Topic.Clear();

            d.GeneralSide.Clear();

            ctx.DeleteObject(d);

            ctx.SaveChanges();
        }