Ejemplo n.º 1
0
        public City Add(int Siruta, decimal Longitude, decimal Latitude, string Name, string Region, int CountyId)
        {
            City p = new City()
            {
                Siruta    = Siruta,
                Longitude = Longitude,
                Latitude  = Latitude,
                Name      = Name,
                Region    = Region,
                CountyId  = CountyId
            };

            Repository.Add(p);

            return(p);
        }
Ejemplo n.º 2
0
 public async Task <ActionResult <CityDto> > PostEvent(CityDto cityDto)
 {
     try
     {
         var mappedEntity = _mapper.Map <CityModel>(cityDto);
         _cityRepo.Add(mappedEntity);
         if (await _cityRepo.Save())
         {
             return(Created($"/api/v1.0/city/{mappedEntity.CityId}", _mapper.Map <CityDto>(mappedEntity)));
         }
     }
     catch (Exception e)
     {
         return(this.StatusCode(StatusCodes.Status500InternalServerError, $"Database Failure: {e.Message}"));
     }
     return(BadRequest());
 }
Ejemplo n.º 3
0
        public async Task <ReturnedUpload> UploadCityAsync(CityUploadDto cityUploadDto)
        {
            var cityFromMap = _mapper.Map <City>(cityUploadDto);

            cityFromMap.Alpha2Code     = InfraData.CountriesCodes[cityUploadDto.Country].Alpha2Code;
            cityFromMap.Alpha3Code     = InfraData.CountriesCodes[cityUploadDto.Country].Alpha3Code;
            cityFromMap.CurrenciesCode = InfraData.CountriesCodes[cityUploadDto.Country].CurrenciesCode;

            _cityRepo.Add(cityFromMap);
            bool successful = await _cityRepo.SaveChangesAsync();

            ReturnedUpload result = new ReturnedUpload
            {
                CityFromMap      = cityFromMap,
                UploadSuccessful = successful
            };

            return(result);
        }