예제 #1
0
        public async Task <int> AddAirport(airports airport)
        {
            try
            {
                using (IDbConnection dbConnection = Connection)
                {
                    dbConnection.Open();
                    DynamicParameters parameters = new DynamicParameters();
                    parameters.Add("@ident", airport.ident);
                    parameters.Add("@type", airport.type);
                    parameters.Add("@name", airport.name);
                    parameters.Add("@latitude_deg", airport.latitude_deg);
                    parameters.Add("@longitude_deg", airport.longitude_deg);
                    parameters.Add("@elevation.ft", airport.elevation_ft);
                    parameters.Add("@continent", airport.continent);
                    parameters.Add("@iso_country", airport.iso_country);
                    parameters.Add("@iso_region", airport.iso_region);
                    parameters.Add("@municipality", airport.municipality);
                    parameters.Add("@scheduled_service", airport.scheduled_service);
                    parameters.Add("@gps_code", airport.gps_code);
                    parameters.Add("@iata_code", airport.iata_code);
                    parameters.Add("@local_code", airport.local_code);
                    parameters.Add("@home_link", airport.home_link);
                    parameters.Add("@wikipedia_link", airport.wikipedia_link);
                    parameters.Add("@keywords", airport.keywords);

                    return(await SqlMapper.ExecuteAsync(dbConnection, "AddAirport", param : parameters, commandType : CommandType.StoredProcedure));
                }
            }catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #2
0
 public IActionResult UpdateAirport([FromBody] airports airport)
 {
     if (ModelState.IsValid)
     {
         _airportService.UpdateAirport(airport);
         return(Ok());
     }
     return(BadRequest());
 }
예제 #3
0
 public IActionResult AddAirport([FromBody] airports airport)
 {
     if (ModelState.IsValid)
     {
         _airportService.AddAirport(airport);
         return(CreatedAtAction(nameof(GetAirportById), new { id = airport.id }, airport));
     }
     return(BadRequest());
 }
예제 #4
0
        public async Task <Response> AddAirport(airports airport)
        {
            Response response = _utilities.InitializeResponse();

            try
            {
                int addedAirport = await _airportRepository.AddAirport(airport);

                if (addedAirport > 0)
                {
                    response.Data = "Airport Saved Sucessfully!";
                }
                if (addedAirport == 0)
                {
                    return(_utilities.UnsuccessfulResponse(response, "Unable to Save Airport"));
                }
            }
            catch (Exception ex)
            {
                response = _utilities.CatchException(response);
                _logger.LogError($"{ex.Message} REQUEST BODY => REQUEST ID => {response.RequestId}");
            }
            return(response);
        }
예제 #5
0
 public async Task <Response> UpdateAirport(airports airport)
 {
     throw new NotImplementedException();
 }