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());
        }
Example #4
0
        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);
        }
Example #5
0
        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);
        }
Example #6
0
 public void Update()
 {
     Contragents.Clear();
     Contragents.AddRange(GetContragents(_context));
 }