コード例 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Switch33KvIsolatorId,TypeIsolatorSwitch,SwitchID,NominalVoltage,BreakingType,ManufactureMonthAndYear,InstallationDate,NormalStatus,RatedCurrent,RatedVoltage,ConnectionStatus,SwitchNo,FeederLineId,SubstationId")] TblSwitch33KvIsolator tblSwitch33KvIsolator)
        {
            if (id != tblSwitch33KvIsolator.Switch33KvIsolatorId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(tblSwitch33KvIsolator);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TblSwitch33KvIsolatorExists(tblSwitch33KvIsolator.Switch33KvIsolatorId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["SubstationId"] = new SelectList(_context.TblSubstation, "SubstationId", "SubstationId", tblSwitch33KvIsolator.SubstationId);
            ViewData["FeederLineId"] = new SelectList(_context.TblFeederLine, "FeederLineId", "FeederLineId", tblSwitch33KvIsolator.FeederLineId);
            return(View(tblSwitch33KvIsolator));
        }
コード例 #2
0
        public async Task <IActionResult> Create([Bind("Switch33KvIsolatorId,TypeIsolatorSwitch,SwitchID,NominalVoltage,BreakingType,ManufactureMonthAndYear,InstallationDate,NormalStatus,RatedCurrent,RatedVoltage,ConnectionStatus,SwitchNo,FeederLineId,SubstationId")] TblSwitch33KvIsolator tblSwitch33KvIsolator)
        {
            if (ModelState.IsValid)
            {
                _context.Add(tblSwitch33KvIsolator);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["SubstationId"] = new SelectList(_context.TblSubstation, "SubstationId", "SubstationId", tblSwitch33KvIsolator.SubstationId);
            ViewData["FeederLineId"] = new SelectList(_context.TblFeederLine, "FeederLineId", "FeederLineId", tblSwitch33KvIsolator.FeederLineId);
            return(View(tblSwitch33KvIsolator));
        }