//Borrar reserva con id de reserva inválido
        public void DeleteReservationIdExCommandTest()
        {
            //Obtiene comando para borrar
            DeleteReservationCommand command = CommandFactory.CreateDeleteReservationCommand(-1);

            Assert.Throws <ValidationErrorException>(delegate { command.Execute(); });
        }
Esempio n. 2
0
        public ActionResult <IEnumerable <String> > Delete(int id_res)
        {
            try{
                DeleteReservationCommand command = CommandFactory.CreateDeleteReservationCommand(id_res);

                command.Execute();

                return(StatusCode(200, "Se elimino satisfactoriamente"));
            }catch (ValidationErrorException ex)
            {
                return(BadRequest(ex.Message));
            }catch (Exception ex) {
                return(BadRequest(ex.Message));
            }
        }
        public void DeleteReservationCommandTest()
        {
            FlightResDTO flightDTO = new FlightResDTO("", "2019-7-6 23:00", 1, 1, 1);

            //Crea la entidad por medio del mapper devuelvo del factory
            ReservationFlightMapper ResFlightMapper = MapperFactory.CreateReservationFlightMapper();
            Entity entity = ResFlightMapper.CreateEntity(flightDTO);

            //Instancia el comando por medio del factory pasandole la entidad al constructor
            AddReservationFlightCommand command = CommandFactory.CreateAddReservationFlightCommand((FlightRes)entity);

            //Ejecuta y obtiene el resultado del comando
            command.Execute();
            int id_res = command.GetResult();

            //Obtiene comando para borrar
            DeleteReservationCommand command2 = CommandFactory.CreateDeleteReservationCommand(id_res);

            command2.Execute();
        }