public virtual void Save(TEntity model, bool commit = true) { DbSet.Add(model); if (commit) { Context.SaveChanges(); } }
public override void TestInitialize() { base.TestInitialize(); Assert.AreEqual(0, db.Countries.Count()); for (var i = 0; i < count; i++) { db.Countries.Add(GetRandom.Object <CountryDbRecord>()); db.SaveChanges(); } }
public ActionResult Create([Bind(Include = "Id,CountryName,CountryCode,Capital")] Country country) { if (ModelState.IsValid) { db.Countries.Add(country); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(country)); }
public void Create(CityModel cityModel) { var city = _mapper.Map <City>(cityModel); // await _dbContext.Country.AddAsync(country); // await _dbContext.SaveChangesAsync(); _dbContext.Add(city).State = EntityState.Added; _dbContext.SaveChanges(); }
public Country AddCountry(Country country) { _context.Countries.Add(country); _context.SaveChanges(); return(country); }