コード例 #1
0
 public void Add(Aluguel aluguel)
 {
     try
     {
         _aluguelRepository.Add(aluguel);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
コード例 #2
0
        public override Task <CommandResult> Handle(AlugarVeiculoCommand request, CancellationToken cancellationToken)
        {
            var aluguel = new Aluguel(request.ClienteId);

            if (aluguel.Valid)
            {
                aluguel.Efetivar();
                _aluguelRepsitory.Add(aluguel);
                aluguel.RaiseEvents(_mediator);

                return(Task.FromResult(CommandResult.Ok(aluguel.Id.ToString(), CommandResultResourceAction.Created)));
            }

            return(Task.FromResult(CommandResult.Error(aluguel.Notifications)));
        }