public static CountryResponse GetAllCountries() { var response = new CountryResponse(); var countryRepository = new CountryRepository(); try { var listCountries = countryRepository.Query().Where(x => x.is_active == 1).ToList(); foreach (var country in listCountries) { countryRepository.Detach(country); response.Countries.Add(AutoMapper.Mapper.Map<country, countryDto>(country)); } } catch (InvalidOperationException exc) { log.Error(exc); response.Message = exc.Message; response.Acknowledge = AcknowledgeType.FAILURE; } catch (ArgumentNullException exc) { log.Error(exc); response.Message = exc.Message; response.Acknowledge = AcknowledgeType.FAILURE; } catch (NullReferenceException exc) { log.Error(exc); response.Message = exc.Message; response.Acknowledge = AcknowledgeType.FAILURE; } catch (OptimisticConcurrencyException exc) { log.Error(exc); response.Message = exc.Message; response.Acknowledge = AcknowledgeType.FAILURE; } catch (UpdateException exc) { log.Error(exc); response.Message = exc.Message; response.Acknowledge = AcknowledgeType.FAILURE; } finally { countryRepository.Dispose(); } return response; }