public void Execute(EditCityDto request) { var city = _context.Cities.Find(request.Id); if (city == null) { throw new EntityNotFoundException(request.Id, typeof(City)); } _validator.ValidateAndThrow(request); var newCity = _mapper.Map <City>(request); _mapper.Map(request, city); _context.SaveChanges(); }
public IActionResult Put(int id, [FromBody] EditCityDto dto, [FromServices] IEditCityCommand command) { dto.Id = id; _executor.ExecuteCommand(command, dto); return(NoContent()); }