private void AddingToStorageFailedInvoke( DateTimeOffset date, string message, string contactId, ReminderItemStatus status, Exception exception) { AddingToStorageFailed?.Invoke( this, new AddingToStorageFailedEventArgs( date, message, contactId, status, exception)); }
private void AddingToStorageFailedInvoke(ReminderItem item, Exception exception) { AddingToStorageFailed?.Invoke( this, new AddingToStorageFailedEventArgs(item, exception)); }
public ReminderDomain( IReminderStorage storage, IReminderReceiver receiver, TimeSpan awaitingRemindersCheckingPeriod, TimeSpan readyRemindersSendingPeriod) { _storage = storage; _receiver = receiver; _awaitingRemindersCheckingPeriod = awaitingRemindersCheckingPeriod; _readyRemindersSendingPeriod = readyRemindersSendingPeriod; _receiver.MessageReceived += (s, e) => { MessageReceived?.Invoke( this, new MessageReceivedEventArgs { ContactId = e.ContactId, Message = e.Message }); ParsedMessage parsedMessage; try { parsedMessage = MessageParser.Parse(e.Message); MessageParsingSuccedded?.Invoke( this, new MessageParsingSucceddedEventArgs { ContactId = e.ContactId, Date = parsedMessage.Date, Message = parsedMessage.Message }); } catch (Exception ex) { MessageParsingFailed?.Invoke( this, new MessageParsingFailedEventArgs { ContactId = e.ContactId, Message = e.Message, ParsingException = ex }); return; } var item = new ReminderItem( parsedMessage.Date, parsedMessage.Message, e.ContactId); try { storage.Add(item); AddingToStorageSucceeded?.Invoke( this, new AddingToStorageSucceddedEventArgs { ContactId = e.ContactId, Message = e.Message }); } catch (Exception ex) { AddingToStorageFailed?.Invoke( this, new AddingToStorageFailedEventArgs { ContactId = e.ContactId, Message = e.Message, AddingException = ex }); } }; }