コード例 #1
0
    public void PerformCommand(ICommand cmd)
    {
        var commandHandler  = _commandHandlers[cmd.GetType()];
        var resultingEvents = commandHandler(cmd);

        foreach (var evt in resultingEvents)
        {
            _eventsChannel.Publish(evt);
        }
    }
コード例 #2
0
 public ActionResult Create(CustomerEditViewModel model)
 {
     if (ModelState.IsValid)
     {
         if (_customerRepository.GetByPersonNummer(model.PersonNummer) != null)
         {
             ModelState.AddModelError("PersonNummer", "Finns redan");
         }
         else
         {
             _customerRepository.Add(new Customer {
                 PersonNummer = model.PersonNummer, Name = model.Namn
             });
             _eventChannel.Publish(new NewCustomerCreated {
                 PersonNummer = model.PersonNummer
             });
             return(RedirectToAction(nameof(Index)));
         }
     }
     return(View(model));
 }
コード例 #3
0
 public void Publish(T message)
 {
     eventChannel.Publish(message);
 }