Beispiel #1
0
        public async Task <ActionResult <Flights> > Get([FromQuery] string relative_To)
        {
            string urlRequest = Request.QueryString.Value;
            IEnumerable <Flights> flightList = new List <Flights>();
            // The pattern we asked for.
            string patternAndSync     = @"^?relative_to=(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})Z+(&sync_all)$";
            string patternWithoutSync = @"^?relative_to=(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})Z$";

            // Check if the givven dateTime in relative_to is availible.
            if (!CheckObjects.CheckDateTime(relative_To))
            {
                return(BadRequest());
            }
            if (Regex.IsMatch(urlRequest, patternAndSync))
            {
                flightList = await flightManager.GetFlightsByDateTimeAndSync(relative_To);
            }
            else if (Regex.IsMatch(urlRequest, patternWithoutSync))
            {
                flightList = flightManager.GetFlightsByDateTime(relative_To);
            }
            else
            {
                return(BadRequest());
            }
            if (flightList == null)
            {
                return(NotFound(flightList));
            }
            return(Ok(flightList));
        }
Beispiel #2
0
        public ActionResult Post([FromBody] FlightPlan flightPlan)
        {
            if (!CheckObjects.CheckFlightPlan(flightPlan))
            {
                return(BadRequest());
            }
            if (!CheckObjects.CheckDateTime(flightPlan.Location.DateTime))
            {
                return(BadRequest());
            }
            string idOfAddedFlightPlan = flightPlanManager.AddFlightPlan(flightPlan);

            return(CreatedAtAction(actionName: "GetFlightPlan",
                                   new { id = idOfAddedFlightPlan }, flightPlan));
        }