Exemplo n.º 1
0
        public async Task <ActionResult> GetFlightSchedule(string aircraftRegistration, string station, string date)
        {
            DateTime scheduleDate;

            if (string.IsNullOrWhiteSpace(aircraftRegistration))
            {
                return(BadRequest("Aircraft Registration should not be blank"));
            }
            if (string.IsNullOrWhiteSpace(station))
            {
                return(BadRequest("Station should not be blank"));
            }
            if (string.IsNullOrWhiteSpace(date))
            {
                return(BadRequest("Date should not be blank"));
            }
            if (!DateTime.TryParseExact(date,
                                        "yyyy-MM-dd",
                                        CultureInfo.InvariantCulture,
                                        DateTimeStyles.None,
                                        out scheduleDate))
            {
                return(BadRequest("Date format is not correct"));
            }

            var data = await db.Get(aircraftRegistration, scheduleDate, station);

            return(Ok(data));
        }