public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Country,City,Oblast,Region")] Contragents contragents) { if (id != contragents.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(contragents); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ContragentsExists(contragents.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(contragents)); }
public async Task <IActionResult> Create([Bind("Id,Name,Country,City,Oblast,Region")] Contragents contragents) { if (ModelState.IsValid) { _context.Add(contragents); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(contragents)); }
public IActionResult PostContragents([FromBody] Contragents contragent) { if (!ModelState.IsValid) { return(BadRequest("Not a valid model")); } _context.contragents.Add(contragent); _context.SaveChanges(); return(Ok()); }
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { if (this.comboBox1.SelectedIndex == 0) { FillDataGrid(); return; } ComboBox comb = sender as ComboBox; SelectedContr = comb.SelectedItem as Contragents; this.FillDataGrid(1); }
public bool AddContragent(string name) { var contrag = from c in datacontext.GetTable <Contragents>() where c.Name == name select c; if (contrag.Count() > 0) { return(false); } var newContrag = new Contragents { Name = name }; datacontext.GetTable <Contragents>().InsertOnSubmit(newContrag); datacontext.SubmitChanges(); return(true); }
public void Update() { Contragents.Clear(); Contragents.AddRange(GetContragents(_context)); }