public static async Task <IActionResult> UpdateAirplane([HttpTrigger(AuthorizationLevel.Function, "put", Route = "airplanes/{regNo}")] HttpRequest req, string regNo, ILogger log)
        {
            log.LogInformation($"Update existing airplane request");

            try
            {
                string         _RequestBody = await new StreamReader(req.Body).ReadToEndAsync();
                AirplaneEntity _Entity      = JsonConvert.DeserializeObject <AirplaneEntity>(_RequestBody);

                if (await AirplaneRepo.Get(regNo) != null)
                {
                    await AirplaneRepo.Update(regNo, _Entity);
                }
                else
                {
                    return(new NotFoundResult());
                }
            }
            catch (Exception _Exception)
            {
                log.LogError(_Exception.Message);
                return(new NotFoundResult());
            }

            return(new OkResult());
        }
        public static async Task <IActionResult> GetAllAirplanes([HttpTrigger(AuthorizationLevel.Function, "get", Route = "airplanes/")] HttpRequest req, ILogger log)
        {
            log.LogInformation("Get All Airplanes Requested");

            List <AirplaneEntity> _Airplanes = await AirplaneRepo.Get();

            return(new JsonResult(_Airplanes));
        }
        public static async Task <IActionResult> GetSingleAirplane([HttpTrigger(AuthorizationLevel.Function, "get", Route = "airplanes/{regNo}/")] HttpRequest req, string regNo, ILogger log)
        {
            log.LogInformation($"GET single airplane {regNo}");

            AirplaneEntity _Result = null;

            try
            {
                _Result = await AirplaneRepo.Get(regNo);
            }
            catch (Exception _Exception)
            {
                log.LogError(_Exception.Message);
            }

            if (_Result == null)
            {
                return(new NotFoundResult());
            }

            return(new JsonResult(_Result));
        }
        public static async Task <IActionResult> RemoveAirplane([HttpTrigger(AuthorizationLevel.Function, "delete", Route = "airplanes/{regNo}")] HttpRequest req, string regNo, ILogger log)
        {
            log.LogInformation($"Remove airplane request");

            try
            {
                if (await AirplaneRepo.Get(regNo) != null)
                {
                    await AirplaneRepo.Remove(regNo);
                }
                else
                {
                    return(new NotFoundResult());
                }
            }
            catch (Exception _Exception)
            {
                log.LogError(_Exception.Message);
                return(new NotFoundResult());
            }

            return(new OkResult());
        }