public ActionResult <Entity> Post([FromBody] Flight flight)
 {
     // Console.WriteLine("entro al try");
     try
     {
         var validator = new FlightValidator(flight);
         validator.Validate();
         FlightMapper     _flightMapper     = MapperFactory.createFlightMapper();
         FlightDTO        _flight           = _flightMapper.CreateDTO(flight);
         AddFlightCommand _addFlightCommand = CommandFactory.AddFlightCommand(_flight);
         _addFlightCommand.Execute();
         return(Ok(new { Message = "¡Vuelo creado con éxito!" }));
     }
     catch (ValidationErrorException ex)
     {
         return(BadRequest(new { ex.Message }));
     }
     catch (DbErrorException ex)
     {
         return(BadRequest(new { ex.Message }));
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.ToString());
         return(null);
     }
 }
Пример #2
0
 public TicketService(IUnitOfWork uof)
 {
     _uof          = uof;
     _ticketMapper = new TicketMapper();
     _flightMapper = new FlightMapper();
 }
Пример #3
0
 public FlightCrudFactory()
 {
     mapper = new FlightMapper();
     dao    = SqlDao.GetInstance();
 }