Esempio n. 1
0
        private void ReminderReceiver_MessageReceived(
            object sender,
            MessageReceivedEventArgs e)
        {
            if (e.Message.ToLower() == "help")
            {
                _sender.Send(e.ContactId, MessageParser.GetHelpMessage());
                return;
            }

            var parsedMessage = MessageParser.Parse(e.Message);

            if (parsedMessage != null)
            {
                var reminder = new ReminderItemRestricted
                {
                    ContactId = e.ContactId,
                    Message   = parsedMessage.Message,
                    Date      = parsedMessage.Date,
                    Status    = ReminderItemStatus.Awaiting
                };

                _storage.Add(reminder);

                _sender.Send(e.ContactId, "Ок, напомню");

                AddingSuccedded?.Invoke(
                    this,
                    new AddingSuccededEventArgs(
                        new AddReminderModel(
                            reminder.ContactId,
                            reminder.Message,
                            reminder.Date)));
            }
            else
            {
                _sender.Send(
                    e.ContactId,
                    "Не понимаю =(");
                _sender.Send(
                    e.ContactId,
                    "Для помощи введите help");
            }
        }