public JsonResult Edit([FromForm] CityForm cityForm) { City city = _context.Cities.FirstOrDefault(u => u.Id == cityForm.Id); city.Name = cityForm.Name; city.PostalCode = cityForm.PostalCode; _context.SaveChanges(); return(Json(city)); }
public JsonResult Add([FromForm] CityForm cityForm) { City city = new City(); city.Name = cityForm.Name; city.PostalCode = cityForm.PostalCode; //add user to database in order to generate id; _context.Cities.Add(city); _context.SaveChanges(); return(Json(city)); }
private void добавить√ородToolStripMenuItem_Click(object sender, EventArgs e) { CityForm cityForm = new CityForm(); cityForm.ShowDialog(); }