public IActionResult PutContinent(int id, [FromBody] ContinentInApi continentIn)
 {
     logger.LogInformation($"Put api/continent/ called");
     if (continentIn == null)
     {
         return(BadRequest());
     }
     try
     {
         if (continentManager.Find(id) == null)
         {
             Domain.Models.Continent continent        = ContinentMapper.ContinentInMapper(countryManager, continentIn);
             Domain.Models.Continent continentCreated = continentManager.AddContinent(continent);
             ContinentOutApi         continentOut     = ContinentMapper.ContinentOutMapper(hostUrl, continentCreated);
             return(CreatedAtAction(nameof(GetContinent), new { id = continentOut.Id }, continentOut));
         }
         Domain.Models.Continent continentUpdate = ContinentMapper.ContinentInMapper(countryManager, continentIn);
         continentUpdate.Id = id;
         continentManager.UpdateContinent(id, continentUpdate);
         return(new NoContentResult());
     }
     catch (Exception ex)
     {
         logger.LogError(ex.Message);
         return(BadRequest(ex.Message));
     }
 }
 public ActionResult <ContinentInApi> PostContinent([FromBody] ContinentInApi continentAPI)
 {
     logger.LogInformation($"Post api/continent/ called");
     try
     {
         if (continentAPI == null)
         {
             return(BadRequest());
         }
         Domain.Models.Continent continent        = ContinentMapper.ContinentInMapper(countryManager, continentAPI);
         Domain.Models.Continent continentCreated = continentManager.AddContinent(continent);
         if (continentCreated != null)
         {
             ContinentOutApi continentOut = ContinentMapper.ContinentOutMapper(hostUrl, continentCreated);
             return(CreatedAtAction(nameof(GetContinent), new { id = continentOut.Id }, continentOut));
         }
         else
         {
             logger.LogError("Continent can not be null.");
             return(NotFound("Continent can not be null."));
         }
     }
     catch (Exception ex)
     {
         logger.LogError(ex.Message);
         return(NotFound(ex.Message));
     }
 }
        public static Continent ContinentInMapper(CountryManager countryManager, ContinentInApi continentIn)
        {
            Continent continent = new Continent();

            continent.Name = continentIn.Name;
            if (continentIn.Countries != null)
            {
                foreach (var countryId in continentIn.Countries)
                {
                    Country country = countryManager.Find(countryId);
                    continent.AddCountry(country);
                }
            }
            return(continent);
        }