Пример #1
0
        public void Save(DefaultAutomaticReply automaticReply)
        {
            var filter = Builders <DefaultAutomaticReply> .Filter.Where(v => v.Type == automaticReply.Type && v.Language == automaticReply.Language);

            _collection.ReplaceOne(filter, automaticReply, new UpdateOptions {
                IsUpsert = true
            });
        }
Пример #2
0
        public void Process(DefaultAutomaticReplyDefined @event)
        {
            var reply = _defaultAutomaticReplies.GetById(@event.Id);

            if (reply == null)
            {
                reply = new DefaultAutomaticReply(@event.Id)
                {
                    Language = @event.Language,
                    Message  = @event.Message,
                    Type     = (AutomaticReplyType)@event.Type
                };

                _defaultAutomaticReplies.Insert(reply);
            }
            else
            {
                reply.Language = @event.Language;
                reply.Message  = @event.Message;
                reply.Type     = (AutomaticReplyType)@event.Type;

                _defaultAutomaticReplies.Update(reply);
            }
        }