public void Dado_um_ConfirmeReservaCommand_valido_a_reserva_deve_ser_confirmada() { var cliente = _clientRepository.GetById(Guid.NewGuid()); var sessao = _sessaoRepository.GetById(Guid.NewGuid()); var reserva = new Reserva(cliente, sessao); reserva.AdicionarIngresso(new Ingresso("Jose", sessao.Poltrona[0])); _reservaRepository.Add(reserva); var command = new ConfirmeReservaCommand(reserva.Id); var commandResult = (GenericCommandResult)_handler.Handle(command); Assert.IsTrue(commandResult.Sucess); Assert.AreEqual(reserva.Status, EStatusReserva.PagamentoConcluido); }
public IActionResult Crate([FromBody] Reserva reserva) { /*Verifica Se alguma reserva para o quarto selecionado dentro da * lista de reservas para aquele quarto no periodo selecionado*/ if (reserva == null || !_reservaRepositorio.Disponivel(reserva)) { return(BadRequest()); } _reservaRepositorio.Add(reserva); return(CreatedAtRoute("GetReserva", new { id = reserva.ReservaId }, reserva)); }
public IActionResult Create([FromBody] Reserva reserva) { if (reserva == null) { return(BadRequest()); } _repositorio.Add(reserva); return(CreatedAtRoute("GetReserva", new { id = reserva.Id }, reserva)); }
public IActionResult PostReserva([FromBody] Reserva reserva) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _reservaRepository.Add(reserva); return(CreatedAtAction("GetReserva", new { id = reserva.Id }, reserva)); }
public bool AddReserva(ReservaDTO dto) { dto.estado = ReservaEstado.NaoCumprida.ToString(); Reserva reserva = _mapper.Map <Reserva>(dto); if (GetReserva(dto.dataInicio.ToString(), dto.dataFim.ToString(), dto.obra.titulo, dto.utente) == null) { _reservaRepository.Add(reserva); return(true); } return(false); }
public async ValueTask <ICommandResult> Handle(SimularReservaCommand command) { if (!command.Validate()) { AddNotifications(command); return(new CommandResult(false, base.Notifications)); } var entityVeiculo = await _veiculoRepository.GetById(command.VeiculosId).ConfigureAwait(true); var entityCliente = await _clienteRepository.GetById(command.ClienteId).ConfigureAwait(true); if (entityCliente == null) { AddNotification("Cliente", "Cliente nao Encontrado."); return(new CommandResult(false, base.Notifications)); } if (entityVeiculo == null) { AddNotification("Veiculo", "Veiculo Nao Encontrado"); return(new CommandResult(false, base.Notifications)); } var entityReserva = new Reserva(command.Agencia, entityCliente.Id, entityVeiculo.Id, command.Grupo, command.DataInicioReserva, command.DataFimReserva, command.Diarias, true); await _reservaRepository.Add(entityReserva); var result = await _reservaRepository.SaveChanges().ConfigureAwait(true); if (!result) { AddNotification("Reserva", "Erro ao Inserir Reserva"); return(new CommandResult(false, base.Notifications)); } return(new CommandResult(true)); }
//Cadastrar a reserva não quer dizer que ela foi comprada // Tera um handler para confirmar reserva // Ai sim é persistido, mas para outras pessoas, a reserva ja foi feita public ICommandResult Handle(CreateReservaCommand command) { command.Validate(); if (command.Invalid) { return(new GenericCommandResult(false, "Dados incorretos", command.Notifications)); } var cliente = _clienteRepository.GetById(command.ClienteId); var sessao = _sessaoRepository.GetById(command.SessaoId); var poltronas = _sessaoRepository.GetPoltronasByIds(sessao.Id, ExtractGuids.Extract(command)); //Verificar se poltronas estão ocupadas if (IsPoltronasOcuped(poltronas)) { return(new GenericCommandResult(false, "Algumas poltronas selecionadas já estão ocupadas", poltronas)); } var reserva = new Reserva(cliente, sessao); var ingressos = CreateIngressos(command.Ingressos, poltronas); reserva.AdicionarIngresso(ingressos); AddNotifications(reserva); if (Invalid) { return(new GenericCommandResult(false, "Problema ao gerar reserva", this.Notifications)); } _reservaRepository.Add(reserva); return(new GenericCommandResult(true, "Reserva cadastrado, aguardando pagamento", reserva)); //Verifica o estado das poltronas //Utilizar Dapper ou buscar estas informações na tela }
public async Task <Reserva> Save(Reserva entity) { //var qtdDias = entity.DataFim - entity.DataInicio; //entity.CacheTotal = qtdDias.Days * entity.Artista. return(await _reservaRepository.Add(entity)); }