/// <summary> /// <see cref="Microsoft.Samples.NLayerApp.Application.MainModule.CustomersManagement.ICustomerManagementService"/> /// </summary> /// <param name="countryName"><see cref="Microsoft.Samples.NLayerApp.Application.MainModule.CustomersManagement.ICustomerManagementService"/></param> /// <returns><see cref="Microsoft.Samples.NLayerApp.Application.MainModule.CustomersManagement.ICustomerManagementService"/></returns> public List <Country> FindCountriesByName(string countryName) { CountryNameSpecification spec = new CountryNameSpecification(countryName); return(_countryRepository.GetBySpec(spec as ISpecification <Country>) .ToList()); }
public IQueryable <Country> GetByName(string name) { CountryNameSpecification specification = new CountryNameSpecification(name); return(_dbSet .AsNoTracking() .Where(specification.ToExpression())); }
public void FindCountriesByName_Invoke_Test() { //Arrange IMainModuleUnitOfWork context = GetUnitOfWork(); ITraceManager traceManager = this.GetTraceManager(); ICountryRepository repository = new CountryRepository(context, traceManager); string name = "Germany"; CountryNameSpecification spec = new CountryNameSpecification(name); //Act IEnumerable <Country> countries = repository.GetBySpec(spec); //Assert Assert.IsNotNull(countries); Assert.IsTrue(countries.Count() > 0); }
/// <summary> /// <see cref="Microsoft.Samples.NLayerApp.Application.MainModule.CustomersManagement.ICustomerManagementService"/> /// </summary> /// <param name="countryName"><see cref="Microsoft.Samples.NLayerApp.Application.MainModule.CustomersManagement.ICustomerManagementService"/></param> /// <returns><see cref="Microsoft.Samples.NLayerApp.Application.MainModule.CustomersManagement.ICustomerManagementService"/></returns> public List <Country> FindCountriesByName(string countryName) { //implement cache-aside pattern List <Country> countryResults = null; CacheKey key = new CacheKey("FindCountriesByName", new { CountryName = countryName }); CacheItemConfig cacheItemConfig = new CacheItemConfig(key, new TimeSpan(0, 10, 0)); if (_cacheManager.TryGet <List <Country> >(cacheItemConfig, out countryResults)) { return(countryResults); } else { CountryNameSpecification spec = new CountryNameSpecification(countryName); countryResults = _countryRepository.GetBySpec(spec as ISpecification <Country>) .ToList(); _cacheManager.Add(cacheItemConfig, countryResults); return(countryResults); } }
/// <summary> /// <see cref="Microsoft.Samples.NLayerApp.Application.MainModule.CustomersManagement.ICustomerManagementService"/> /// </summary> /// <param name="countryName"><see cref="Microsoft.Samples.NLayerApp.Application.MainModule.CustomersManagement.ICustomerManagementService"/></param> /// <returns><see cref="Microsoft.Samples.NLayerApp.Application.MainModule.CustomersManagement.ICustomerManagementService"/></returns> public List<Country> FindCountriesByName(string countryName) { //implement cache-aside pattern List<Country> countryResults = null; CacheKey key = new CacheKey("FindCountriesByName",new {CountryName=countryName}); CacheItemConfig cacheItemConfig = new CacheItemConfig(key, new TimeSpan(0, 10, 0)); if (_cacheManager.TryGet<List<Country>>(cacheItemConfig, out countryResults)) return countryResults; else { CountryNameSpecification spec = new CountryNameSpecification(countryName); countryResults = _countryRepository.GetBySpec(spec as ISpecification<Country>) .ToList(); _cacheManager.Add(cacheItemConfig, countryResults); return countryResults; } }
/// <summary> /// <see cref="Microsoft.Samples.NLayerApp.Application.MainModule.CustomersManagement.ICustomerManagementService"/> /// </summary> /// <param name="countryName"><see cref="Microsoft.Samples.NLayerApp.Application.MainModule.CustomersManagement.ICustomerManagementService"/></param> /// <returns><see cref="Microsoft.Samples.NLayerApp.Application.MainModule.CustomersManagement.ICustomerManagementService"/></returns> public List<Country> FindCountriesByName(string countryName) { CountryNameSpecification spec = new CountryNameSpecification(countryName); return _countryRepository.GetBySpec(spec as ISpecification<Country>) .ToList(); }
public void CountryNameSpecificationShouldBeTrue(string value) { CountryNameSpecification specification = new CountryNameSpecification(value); Assert.IsTrue(specification.IsSatisfiedBy(country)); }