예제 #1
0
        public Country GetCountryViewModel(string code)
        {
            var country = _countryRepository.Find(code);

            country.Population = country.Population.ToIntFormat();
            country.AreaInSqKm = country.AreaInSqKm.ToIntFormat();
            return(country);
        }
예제 #2
0
        private bool AddressIsInZone(Zone zone, Address address)
        {
            var result = false;

            var c = _countryRepository.Find(address.CountryBvin);

            if (c != null)
            {
                foreach (var a in zone.Areas)
                {
                    if (a.CountryIsoAlpha3.Trim().ToLowerInvariant() ==
                        c.IsoAlpha3.Trim().ToLowerInvariant())
                    {
                        // Country matches
                        if (string.IsNullOrWhiteSpace(a.RegionAbbreviation))
                        {
                            // empty region abbreviation means match all
                            return(true);
                        }
                        if (address.RegionBvin.Trim().ToLowerInvariant() ==
                            a.RegionAbbreviation.Trim().ToLowerInvariant())
                        {
                            return(true);
                        }
                    }
                }
            }

            return(result);
        }
예제 #3
0
        public void Find_Returns_Sorted_FoundByIsoCode()
        {
            var data = new List <Country>
            {
                new Country {
                    IsoCode = "CC", Name = "UUU"
                },
                new Country {
                    IsoCode = "BB", Name = "XXX"
                },
                new Country {
                    IsoCode = "DD", Name = "YYY"
                },
                new Country {
                    IsoCode = "AA", Name = "YYY"
                },
            };

            var mockSet     = new Mock <DbSet <Country> >().SetupData(data);
            var mockContext = new Mock <CountryContext>();

            mockContext.Setup(c => c.Countries).Returns(mockSet.Object);

            var service = new CountryRepository(mockContext.Object);

            // Act
            var items = service.Find(new string[] { "BB", "CC" }).ToList();

            Assert.IsNotNull(items);
            Assert.AreEqual(items.Count, 2);
            Assert.AreEqual(items[0].IsoCode, "BB");
            Assert.AreEqual(items[1].IsoCode, "CC");
        }
예제 #4
0
      public void FindCountryTets()
      {
          var context = new ApplicationDbContext();
          var target  = new CountryRepository(context);
          var param   = context.Country.FirstOrDefault();
          IEnumerable <Country> foundItem = target.Find(x => x.Title == param.Title);

          foreach (var item  in foundItem)
          {
              Assert.AreEqual(param.Title, item.Title);
          }
      }
예제 #5
0
 //
 // GET: /Country/Details/5
 public ActionResult Details(int?id)
 {
     return(View(ICN.Find(id)));
 }