protected void ButtonAdd_Click(object sender, EventArgs e) { string countryName = (string)ViewState["CountryName"]; string countryLanguage = (string)ViewState["CountryLanguage"]; if (string.IsNullOrWhiteSpace(countryName) || string.IsNullOrWhiteSpace(countryLanguage)) { return; } SettlementsContext db = new SettlementsContext(); var contId = (int)ViewState["CountryContinentId"]; var foundContinent = db.Continents.Where(x => x.Id == contId).FirstOrDefault(); var newCountry = new Country { Name = countryName, Language = countryLanguage, Population = (int)ViewState["CountryPopulation"], Continend = foundContinent }; db.Countries.Add(newCountry); db.SaveChanges(); }
public SettlementRepository(SettlementsContext dbContext) : base(dbContext) { }
public CountryRepository(SettlementsContext dbContext) : base(dbContext) { }