public void PerformCommand(ICommand cmd) { var commandHandler = _commandHandlers[cmd.GetType()]; var resultingEvents = commandHandler(cmd); foreach (var evt in resultingEvents) { _eventsChannel.Publish(evt); } }
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)); }
public void Publish(T message) { eventChannel.Publish(message); }