Пример #1
0
        public async Task <IHttpActionResult> CreateAirport(AirportDTO model)
        {
            var resultMessage = string.Empty;

            try
            {
                //TraceManager.StartMethodTrace(Traces.IndexStackFrameAsynController, "model: " + JsonConvert.SerializeObject(model));

                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

                var request = DistributedServicesAutoMapper.Map <Domain.BO.Airport.AirportDTO>(model);

                AirportServices.CreateAirport(request);

                resultMessage = SharedLanguage.REQUEST_SUCCESSFUL;

                return(Ok(resultMessage));
            }
            catch (Exception ex)
            {
                resultMessage = ""; //TraceManager.ExceptionErrorTrace(ex, Traces.IndexStackFrameAsynController);
                return(ResponseMessage(HttpHelper.GetHttpResponseErrorMessage(resultMessage)));
            }
            finally
            {
                //TraceManager.FinishMethodTrace(Traces.IndexStackFrameAsynController, "resultMessage: " + resultMessage);
            }
        }
Пример #2
0
        public IHttpActionResult GetAirportsList()
        {
            List <AirportDTO> airportsListResponse = null;

            try
            {
                //TraceManager.StartMethodTrace();

                // get airports list
                var airportsList = AirportServices.GetAirportList();

                airportsListResponse = DistributedServicesAutoMapper.Map <List <AirportDTO> >(airportsList);

                //return airports list
                return(Ok(airportsListResponse));
            }
            catch (Exception ex)
            {
                //if there was a other error then log and returns it to client side
                //TraceManager.ExceptionErrorTrace(ex);
                return(ResponseMessage(HttpHelper.GetHttpResponseErrorMessage(ex.Message)));
            }
            finally
            {
                //TraceManager.FinishMethodTrace(output: "response: " + JsonConvert.SerializeObject(response));
            }
        }
Пример #3
0
        public void UpdateFlight_WhenDataIsCorrect_CheckResult()
        {
            TestEnvironmentManager.DeleteFlightTest(FlightService, FlightDTO.Name);

            if (FlightController.CreateFlight(FlightDTO).Result.GetType().Name.Equals("OkNegotiatedContentResult`1"))
            {
                FlightDTO = DistributedServicesAutoMapper.Map <FlightDTO>(FlightService.GetFlight(new Domain.BO.Flights.FlightDTO {
                    Name = FlightDTO.Name
                }));

                FlightDTO.Name += "_Updated";
                FlightDTO.DepartureAirport.AirportId   = 17;
                FlightDTO.DepartureAirport.Name        = "Málaga (AGP)";
                FlightDTO.DestinationAirport.AirportId = 18;
                FlightDTO.DestinationAirport.Name      = "Sevilla (SEV)";
                var response = FlightController.UpdateFlight(FlightDTO);
                Assert.IsNotNull(response);

                TestEnvironmentManager.DeleteFlightTest(FlightService, FlightDTO.Name);
            }
            else
            {
                Assert.Fail();
            }
        }