public void Handle(MailRequested @event, Dictionary<string, object> metadata)
 {
     using (var context = new SendMailContext())
     {
         context.MailViews.Add(new MailView { Id = @event.Id, From = @event.From, To = string.Join(";", @event.To), Subject = @event.Subject, Body = @event.Body, DateCreated = GetEventDate(metadata), NbTries = 1 });
         context.SaveChanges();
     }
 }
 private static void Update(Guid id, Action<MailView> update, Dictionary<string, object> metadata)
 {
     using (var context = new SendMailContext())
     {
         var mail = context.MailViews.Find(id);
         update(mail);
         mail.DateUpdated = GetEventDate(metadata);
         context.SaveChanges();
     }
 }