public Task <bool> Handle(RegisterNewPersonLotteryCommand message, CancellationToken cancellationToken) { if (!message.IsValid()) { NotifyValidationErrors(message); return(Task.FromResult(false)); } var PersonLottery = new PersonLottery(); if (message.Lottery != null) { PersonLottery = new PersonLottery(Guid.NewGuid(), message.Concurse, message.Game, message.Lottery.Id, message.Person.Id); } else { PersonLottery = new PersonLottery(Guid.NewGuid(), message.Concurse, message.Game, message.Person.Id); } if (_PersonLotteryRepository.GetById(PersonLottery.Id) != null) { Bus.RaiseEvent(new DomainNotification(message.MessageType, "The Person Lottery Id has already been taken.")); return(Task.FromResult(false)); } _PersonLotteryRepository.Add(PersonLottery); if (Commit()) { Bus.RaiseEvent(new PersonLotteryRegisteredEvent(PersonLottery.Id, PersonLottery.Concurse, PersonLottery.Game, PersonLottery.Hits, PersonLottery.Ticket_Amount, PersonLottery.Game_Checked, PersonLottery.Game_Register, PersonLottery.Lottery, PersonLottery.Person)); } return(Task.FromResult(true)); }
public PersonLotteryViewModel GetById(Guid id) { return(_mapper.Map <PersonLotteryViewModel>(_PersonLotteryRepository.GetById(id))); }