public AdminController(CityContext context, UserManager <AppUser> userManager, RoleManager <AppRole> roleManager, IMapper mapper) { _context = context; _userManager = userManager; _roleManager = roleManager; _mapper = mapper; }
private void button2_Click(object sender, EventArgs e) { if (textBox1.Text == "" || textBox2.Text == "") { MessageBox.Show("Поля пустые, внесите данные в оба поля."); } else { Person person = new Person(); using (var context = new CityContext()) { var cities = context.Cities.ToList(); for (int i = 0; i < cities.Count; i++) { if (cities[i].NameSeed == comboBox1.Text) { person = new Person { FullName = textBox1.Text, Phone = textBox2.Text, City = cities[i] } } } ; context.People.AddRange(new List <Person> { person }); context.SaveChanges(); textBox1.Text = ""; textBox2.Text = ""; MessageBox.Show("Контакт внесен!"); } } }
private static void SeedDB() { var ctx = new CityContext(); ctx.Cities.Add(new City { Name = "Kiev", Latitude = 1, Longitude = 1 }); ctx.Cities.Add(new City { Name = "Lviv", Latitude = 1, Longitude = 1 }); ctx.Doctors.Add(new Doctor { CityId = 1, Name = "name1", Specialization = "spec1" }); ctx.Doctors.Add(new Doctor { CityId = 1, Name = "name2", Specialization = "spec2" }); ctx.Doctors.Add(new Doctor { CityId = 1, Name = "name3", Specialization = "spec3" }); ctx.Doctors.Add(new Doctor { CityId = 1, Name = "name4", Specialization = "spec4" }); ctx.Engineers.Add(new Engineer { CityId = 1, Name = "name4", FavoriteVideogame = "game1" }); ctx.SaveChanges(); }
private void button5_Click(object sender, EventArgs e) { using (var context = new CityContext()) { Person p1 = context.People.FirstOrDefault(p => p.FullName == textBox1.Text); if (textBox1.Text != "" && textBox2.Text == "") { if (p1 == null) { MessageBox.Show("Контакт не найден"); } else { textBox2.Text = p1.Phone; } } Person p2 = context.People.FirstOrDefault(p => p.Phone == textBox2.Text); if (textBox1.Text == "" && textBox2.Text != "") { if (p2 == null) { MessageBox.Show("Контакт не найден"); } else { textBox1.Text = p2.FullName; } } } }
public JsonResult GetStates(string country) { using (var db = new CityContext()) { var city = db.Cities.Where(c => c.Country.Name == country).Select(m => m.Name).ToList(); return(Json(city, JsonRequestBehavior.AllowGet)); } }
public JsonResult AllCities() { using (var db = new CityContext()) { var cities = db.Cities.Select(w => w.Name).ToList(); return(Json(cities, JsonRequestBehavior.AllowGet)); } }
public JsonResult GetCities(string str) { using (var db = new CityContext()) { var city = db.Cities.Where(c => c.Name.Contains(str)).Select(m => m.Name).FirstOrDefault(); return(Json(city, JsonRequestBehavior.AllowGet)); } }
public Form1() { InitializeComponent(); context = new CityContext(); context.Cities.Load(); dataGridView1.DataSource = context.Cities.Local.ToBindingList(); }
public static void WriteToDB(IList <CitiesImportModel> myList, string typeOfCity) { var countryCapitalQuery = (from s in myList where s.Capital.Equals(typeOfCity) orderby s.Country ascending select s); using (var dbContext = new CityContext()) { dbContext.Database.Connection.Close(); } var countryGroups = from city in countryCapitalQuery group city by new { city.Country, city.ISO2, city.ISO3 } into countryGroup orderby countryGroup.Key.Country select countryGroup; using (var db = new CityContext()) { foreach (var country in countryGroups) { var countryName = country.Key.Country; var ISO2 = country.Key.ISO2; var ISO3 = country.Key.ISO3; var CountryEntity = new CountryEntity { Name = countryName, ISO2 = ISO2, ISO3 = ISO3 }; db.Countries.Add(CountryEntity); db.SaveChanges(); int id = CountryEntity.CountryID; foreach (var city in country) { var CityEntity = new CityEntity { City_name = city.City_name, Admin_name = city.Admin_name, City_ascii = city.City_ascii, Lat = city.Lat, Lng = city.Lng, Capital = city.Capital, CountryId = id, Population = city.Population }; db.Cities.Add(CityEntity); db.SaveChanges(); } } } }
public override float Score(IAIContext _context) { CityContext context = (CityContext)_context; score = (100f / context.food); //Debug.Log(score + " Food"); //var targets = context._surroundingHexCells; return(this.score); }
public ActionResult About() { ViewBag.Message = "Your application description page."; using (var db = new CityContext()) { var countries = db.Countries.Select(m => m.Name).ToList(); var countryOptions = new SelectList(countries); return(View(countryOptions)); } }
public ActionResult Index() { IEnumerable <City> cities; using (var db = new CityContext()) { cities = db.Cities.ToList(); } return(View(cities)); }
public ActionResult AddCity() { IEnumerable <string> countries; using (var db = new CityContext()) { countries = db.Countries.Select(w => w.Name).ToList(); } return(View(new SelectList(countries))); }
public override float Score(IAIContext _context) { CityContext context = (CityContext) _context; score = (100f/context.oil); //var targets = context._surroundingHexCells; //Debug.Log(score + " Oil"); return this.score; }
public static IOrderedQueryable<CityEntity> ReadCitiesDB(string typeOfCity) { CityContext db = new CityContext(); var city = (from s in db.Cities where s.Capital.Equals(typeOfCity) orderby s.Country ascending select s); return city; }
private void Form1_Load(object sender, EventArgs e) { using (var context = new CityContext()) { var cities = context.Cities.ToList(); foreach (var city in cities) { comboBox1.Items.Add(city.NameSeed); } } }
public ActionResult AddCity(string country, string cityname) { using (var db = new CityContext()) { db.Cities.Add(new City() { Name = cityname, CountryId = db.Countries.FirstOrDefault(w => w.Name == country).Id }); db.SaveChanges(); } return(RedirectToAction("Index")); }
public static List <string> GetSpecialization(string cityName) { using (var ctx = new CityContext()) { var responseDB = (from d in ctx.Doctors join c in ctx.Cities on d.CityId equals c.Id where c.Name == cityName select d.Specialization); return(responseDB.ToList()); } }
private void button1_Click(object sender, EventArgs e) { using (var context = new CityContext()) { Person p2 = context.People.FirstOrDefault(p => p.Phone == textBox3.Text || p.FullName == textBox1.Text); p2.FullName = textBox2.Text; p2.Phone = textBox4.Text; context.SaveChanges(); } textBox1.Text = textBox2.Text = textBox3.Text = textBox4.Text = ""; Close(); }
public string Get() { City city = new City() { CityId = 1, Name = "Alabama", ShortName = "ab" }; CityContext cc = new CityContext(); cc.City.add(city); cc.SaveChanges; }
static void Main() { using (var context = new CityContext()) { context.Cities.Add(new City { Name = "Алматы", PhoneCode = "+7(727)" }); context.SaveChanges(); } Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); }
public static void Initialize(CityContext context) { if (!context.Cities.Any()) { context.Cities.AddRange( new City { name = "Paris" }, new City { name = "Tokyo" }, new City { name = "Soul" } ); context.SaveChanges(); context.Pilots.AddRange( new Pilot { name = "John", company = "USA Airlines", exp = 3 }, new Pilot { name = "Leon", company = "Aeroflot", exp = 2 }, new Pilot { name = "Hiro", company = "Korean Air", exp = 8 } ); context.SaveChanges(); } }
private void button3_Click(object sender, EventArgs e) { if (textBox1.Text == "") { MessageBox.Show("Внесите данные поле ФИО."); } else { using (var context = new CityContext()) { Person person = context.People.FirstOrDefault(p => p.FullName == textBox1.Text); if (person != null) { context.People.Remove(person); context.SaveChanges(); } } textBox1.Text = ""; textBox2.Text = ""; MessageBox.Show("Контакт удален!"); } }
public UserRepo(CityContext context) { _context = context; }
public Repository(CityContext context) { _context = context; }
public CityItemsController(CityContext context) { _context = context; }
public void OnEnable() { _context = new CityContext(this.transform, _targets, _workedHexInfos, _oil + UnityEngine.Random.Range(0, 4), _wood, _water + UnityEngine.Random.Range(0, 4), _food + UnityEngine.Random.Range(0, 4)); }
public CityInfoRepository(CityContext cityContext) { _cityContext = cityContext; }
public CityController(CityContext _context) { context = _context; }
public CityRepo(CityContext context) { _context = context; }