private CityResource CreateLinksForCity(CityResource city) { city.Links.Add( new LinkResource( href: _urlHelper.Link("GetCityForCountry", new { cityId = city.Id }), rel: "self", method: "GET")); city.Links.Add( new LinkResource( href: _urlHelper.Link("UpdateCityForCountry", new { cityId = city.Id }), rel: "update_city", method: "PUT")); city.Links.Add( new LinkResource( href: _urlHelper.Link("PartiallyUpdateCityForCountry", new { cityId = city.Id }), rel: "partially_update_city", method: "PATCH")); city.Links.Add( new LinkResource( href: _urlHelper.Link("DeleteCityForCountry", new { cityId = city.Id }), rel: "delete_city", method: "DELETE")); return(city); }
public async Task <IActionResult> AddCity(CityResource cityResource) { var city = CityMapper.MapCityResourceToCity(cityResource); _cityRepository.AddCity(city); await _unitOfWork.UpdateDatabase(); return(Ok()); }
private CityResource CreateLinksFactory(CityResource city) { city.Links.Add(new LinkResource( urlHelper.Link("GetCity", new { city.CountryId, cityId = city.Id }), "self", "GET")); city.Links.Add(new LinkResource( urlHelper.Link("DeleteCity", new { city.CountryId, cityId = city.Id }), "delete_city", "DELETE")); city.Links.Add(new LinkResource( urlHelper.Link("UpdateCity", new { city.CountryId, cityId = city.Id }), "update_city", "PUT")); city.Links.Add(new LinkResource( urlHelper.Link("UpdatePatialCity", new { city.CountryId, cityId = city.Id }), "update_patial_city", "PATCH")); return(city); }
public static City MapCityResourceToCity(CityResource cityResource) { var city = new City { Id = cityResource.Id, Description = cityResource.Description, Name = cityResource.Name, MapPositionLatitude = cityResource.Location.MapPositionLatitude, MapPositionLongitude = cityResource.Location.MapPositionLongitude, MetersAboveSeaLevel = cityResource.MetersAboveSeaLevel, Population = cityResource.Population, Area = cityResource.Area, PopulationDensity = cityResource.PopulationDensity }; return(city); }
public static CityResource MapCityToCityResource(City city) { var cityResource = new CityResource { Id = city.Id, Description = city.Description, Name = city.Name, MetersAboveSeaLevel = city.MetersAboveSeaLevel, Population = city.Population, Area = city.Area, PopulationDensity = city.PopulationDensity, Location = new Location { MapPositionLatitude = city.MapPositionLatitude, MapPositionLongitude = city.MapPositionLongitude } }; return(cityResource); }
public CityController() { _cityResource = new CityResource(); }
public void TestInitialize() { CityResource = new CityResource(); Helpers.SetBaseAddress(); Helpers.Wipe(); }