예제 #1
0
        public void UpdateCountry(UpdateCountryInput input)
        {
            var country = _mapper.Map <Country>(input);

            country.Id = input.Id;
            _countryManager.Update(country);
        }
예제 #2
0
        public async Task <UpdateCountryPayload> UpdateCountryAsync(UpdateCountryInput input, [ScopedService] GeoDbContext context)
        {
            var country = await context.Countries.FindAsync(input.Id);

            country.Name       = input.Name;
            country.Alpha2Code = input.Alpha2Code;
            country.Alpha3Code = input.Alpha3Code;

            await context.SaveChangesAsync();

            return(new UpdateCountryPayload(country));
        }
예제 #3
0
        public IActionResult PutCountry([FromRoute] int id, [FromBody] UpdateCountryInput country)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != country.Id)
            {
                return(BadRequest());
            }

            _countryService.UpdateCountry(country);

            return(Ok());
        }