public void Execute(CountryDto request) { if (_context.Categories.Find(request.Id) == null) { throw new EntityNotFoundException(request.Id, typeof(Country)); } _validator.ValidateAndThrow(request); var country = _context.Countries.Find(request.Id); _mapper.Map(request, country); _context.SaveChanges(); }
public void Execute(CountryDto request) { validator.ValidateAndThrow(request); var findCountry = context.Countries.Find(request.Id); if (findCountry == null) { throw new EntityNotFoundException(request.Id, typeof(Country)); } var country = context.Countries.Where(x => x.Id == request.Id).First(); mapper.Map(request, country); context.SaveChanges(); }