public IEnumerable Handle(Func <Guid, ParticipantAggregate> al, ReplaceParticipant command) { var agg = al(command.Id); var alternate = CommandQueries.GetParticipant(command.AlternateId); yield return(new ParticipantReplacedWithAlternate { Id = command.Id, ContingentId = alternate.ContingentId, TeamId = alternate.TeamId, Name = agg.Name, AlternateId = command.AlternateId, AlternateName = alternate.Name, Average = alternate.Average, }); }
public JsonResult UseAlternate(ReplaceParticipant command) { //Replace the participant Domain.Dispatcher.SendCommand(command); //Add the alternate to the team var participant = Domain.ParticipantQueries.GetParticipant(command.Id); Domain.Dispatcher.SendCommand( new AddParticipantToTeam { Id = command.AlternateId, TeamId = participant.TeamId }); var alternate = Domain.ParticipantQueries.GetParticipant(command.AlternateId); return(Json(alternate)); }