Beispiel #1
0
        public async Task <IActionResult> Edit(int id, [Bind("ConsumerEnrolledPowerPlantId,Id,PowerPlantId")] ConsumerEnrolledPowerPlant consumerEnrolledPowerPlant)
        {
            if (id != consumerEnrolledPowerPlant.ConsumerEnrolledPowerPlantId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(consumerEnrolledPowerPlant);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ConsumerEnrolledPowerPlantExists(consumerEnrolledPowerPlant.ConsumerEnrolledPowerPlantId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["PowerPlantId"] = new SelectList(_context.PowerPlants, "PowerPlantId", "PowerPlantId", consumerEnrolledPowerPlant.PowerPlantId);
            return(View(consumerEnrolledPowerPlant));
        }
Beispiel #2
0
        public async Task <IActionResult> Create([Bind("ConsumerEnrolledPowerPlantId,Id,PowerPlantId")] ConsumerEnrolledPowerPlant consumerEnrolledPowerPlant)
        {
            if (ModelState.IsValid)
            {
                _context.Add(consumerEnrolledPowerPlant);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["PowerPlantId"] = new SelectList(_context.PowerPlants, "PowerPlantId", "PowerPlantId", consumerEnrolledPowerPlant.PowerPlantId);
            return(View(consumerEnrolledPowerPlant));
        }