Beispiel #1
0
        void SaveProcedure()
        {
            var ap = DataContext as ArgPoint;

            if (ap == null)
            {
                return;
            }

            if (DateTime.Now.Subtract(_lastSave).TotalMilliseconds < 100)
            {
                return;
            }

            _lastSave = DateTime.Now;

            var lastComment = ap.Comment.LastOrDefault();

            //finalize edited comment
            if (!string.IsNullOrWhiteSpace(txtNewComment.Text) &&
                DaoUtils.NEW_COMMENT != txtNewComment.Text)
            {
                if (lastComment == null || (lastComment != null && txtNewComment.Text != lastComment.Text))
                {
                    DaoUtils.HandleCommentCommit(txtNewComment.Text, ap);
                    //txtNewComment.Text = DaoUtils.NEW_COMMENT;
                    txtNewComment.Text = "";
                }
            }

            if (!ap.ChangesPending)
            {
                return;
            }

            ap.ChangesPending = false;

            //save changes
            try
            {
                DbCtx.Get().SaveChanges();
            }
            catch
            {
            }

            if (_sharedClient != null)
            {
                _sharedClient.clienRt.SendStatsEvent(StEvent.BadgeEdited,
                                                     SessionInfo.Get().person.Id,
                                                     ap.Topic.Discussion.Id,
                                                     ap.Topic.Id,
                                                     DeviceType.Wpf);

                _sharedClient.clienRt.SendArgPointChanged(ap.Id, ap.Topic.Id, SessionInfo.Get().person.Id);
            }
        }