Example #1
0
        public IHttpActionResult GetByHourFilter(FlightFilter filter)
        {
            try
            {
                var result = DaoFlight.GetByHour(filter);

                var respuesta = new
                {
                    errorCode    = 0,
                    messageError = "Consulta correcta.",
                    flights      = result
                };

                return(Ok(respuesta));
            }
            catch (Exception ex)
            {
                CatchError.Log4Net("ERROR", ex);
                return(BadRequest(ex.Message));
            }
        }
Example #2
0
        public IHttpActionResult Save(Flight flight)
        {
            try
            {
                var departureCity = flight.DepartureCity;
                var arrivalCity   = flight.ArrivalCity;
                DaoFlight.Save(flight);

                var respuesta = new
                {
                    errorCode    = 0,
                    messageError = $"Se guardo correctamente el vuelo {flight.FlightNumber} de {departureCity.IATACode} a {arrivalCity.IATACode}.",
                    flight       = flight
                };

                return(Ok(respuesta));
            }
            catch (Exception ex)
            {
                CatchError.Log4Net("ERROR", ex);
                return(BadRequest(ex.Message));
            }
        }