Example #1
0
 public void CountryRepository_Should_SaveCountry()
 {
     using (var repo = new CountryRepository())
     {
         Assert.DoesNotThrowAsync(async() => await repo.CreateCountry(new Country
         {
             Name      = "Aruba",
             Continent = "Asia"
         }));
     }
 }
        // POST /api/country
        public async Task <IHttpActionResult> Post(CountryViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            using (var db = new CountryRepository())
            {
                var country = new Country
                {
                    Continent = model.Continent,
                    Name      = model.Name,
                    Created   = DateTime.Now
                };

                await db.CreateCountry(country);
            }

            return(Ok());
        }