示例#1
0
        public async Task <IActionResult> Edit(int id, [Bind("AbId,AbBatWhardId,AbWhardId")] AccountingBatteries accountingBatteries)
        {
            if (id != accountingBatteries.AbId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(accountingBatteries);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AccountingBatteriesExists(accountingBatteries.AbId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["AbBatWhardId"] = new SelectList(_context.WealthHardware, "WhardId", "WhardId", accountingBatteries.AbBatWhardId);
            ViewData["AbWhardId"]    = new SelectList(_context.WealthHardware, "WhardId", "WhardId", accountingBatteries.AbWhardId);
            return(View(accountingBatteries));
        }
示例#2
0
        public async Task <IActionResult> Create([Bind("AbId,AbBatWhardId,AbWhardId")] AccountingBatteries accountingBatteries)
        {
            if (ModelState.IsValid)
            {
                _context.Add(accountingBatteries);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["AbBatWhardId"] = new SelectList(_context.WealthHardware, "WhardId", "WhardId", accountingBatteries.AbBatWhardId);
            ViewData["AbWhardId"]    = new SelectList(_context.WealthHardware, "WhardId", "WhardId", accountingBatteries.AbWhardId);
            return(View(accountingBatteries));
        }