Exemple #1
0
        public GetFleetResponse GetFleet(GetFleetRequest request)
        {
            var response = new GetFleetResponse
            {
                IsSuccessful = false,
                Message      = "",
            };

            try
            {
                var aircraft = _context.Fleet
                               .Include(plane => plane.Aircraft)
                               .Include(plane => plane.Status)
                               .ToList();

                if (aircraft != null && aircraft.Count != 0)
                {
                    response.IsSuccessful    = true;
                    response.Message         = "The airline fleet was found.";
                    response.AirlineAircraft = aircraft;
                }
                else
                {
                    response.IsSuccessful = false;
                    response.Message      = "The airline fleet was not found.";
                }
            }
            catch (Exception ex)
            {
                response.IsSuccessful = false;
                response.Message      = ex.Message;
            }

            return(response);
        }
Exemple #2
0
        public GetFleetResponse GetFleet()
        {
            JsonServiceClient client   = new JsonServiceClient(FLEET_API_ROOT_URL);
            GetFleetResponse  response = client.Get <GetFleetResponse>("fleet" + "?access_token=" + FLEET_ACCESS_TOKEN);

            return(response);
        }
        public IActionResult GetEntireFleet()
        {
            var response = new GetFleetResponse();

            try
            {
                response = _fleetService.GetFleet(new GetFleetRequest());
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }

            if (response.IsSuccessful)
            {
                return(Ok(response.AirlineAircraft));
            }
            else
            {
                return(BadRequest(response.Message));
            }
        }