Пример #1
0
        public void SaveRecord(Message message, MarkQuery query)
        {
            _saveManager.Load();

            Record record = GetRecord(message, query);

            if (record != null)
            {
                _saveManager.Data.Add(record);
            }

            _saveManager.Save();
        }
Пример #2
0
        private Record GetRecord(Message message, MarkQuery query)
        {
            if (!message.ForwardDate.HasValue)
            {
                return(null);
            }

            return(new Record
            {
                MessageId = message.MessageId,
                ChatId = message.Chat.Id,
                DateTime = query?.DateTime ?? _bot.TimeManager.ToLocal(message.ForwardDate.Value),
                Tags = query?.Tags ?? new HashSet <string>()
            });
        }
Пример #3
0
        public Task Mark(ChatId chatId, Message recordMessage, MarkQuery query)
        {
            _saveManager.Load();

            Record record = _saveManager.Data.FirstOrDefault(
                r => (r.ChatId == recordMessage.Chat.Id) && (r.MessageId == recordMessage.MessageId));

            if (record == null)
            {
                return(_bot.Client.SendTextMessageAsync(chatId, "Я не нашёл нужной записи."));
            }

            if (query.DateTime.HasValue)
            {
                record.DateTime = query.DateTime.Value;
            }

            record.Tags = query.Tags;
            _saveManager.Save();
            return(_bot.Client.SendTextMessageAsync(chatId, "Запись обновлена."));
        }
Пример #4
0
 public static bool TryParseMarkQuery(string text, out MarkQuery query)
 {
     query = ParseMarkQuery(text);
     return(query != null);
 }