Пример #1
0
        public IActionResult Update([FromBody] UpdateCityViewModel city, Guid id)
        {
            if (id == Guid.Empty)
            {
                _logger.LogWarning("Invalid id specifies");
                return(BadRequest());
            }
            var cityId = _storage.GetById(id);

            if (cityId == null)
            {
                _logger.LogWarning("City with id {0} is not found", id);
                return(NotFound());
            }
            if (city == null)
            {
                _logger.LogWarning("City with id {0} is not found", id);
                return(BadRequest());
            }
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }
            var model = new City(city.Name, city.Description, city.Population, id);

            _storage.Update(model);

            return(Ok());
        }
 public IActionResult Update(Guid id, [FromBody] UpdateCityViewModel model)
 {
     CityStorage.Instance.Update(
         id,
         new City
     {
         Name        = model.Name,
         Population  = model.Population,
         Descryption = model.Descryption
     }
         );
     return(Ok());
 }