예제 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Sitename,Contactname,ContactPhone,ContactEmail,Capacity,UsefulLife,ProjectCost,Loan,ConsumerID")] PowerplantSite powerplantSite)
        {
            if (id != powerplantSite.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(powerplantSite);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PowerplantSiteExists(powerplantSite.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ConsumerID"] = new SelectList(_context.Consumers, "ConsumerID", "ConsumerID", powerplantSite.ConsumerID);
            return(View(powerplantSite));
        }
예제 #2
0
        public async Task <IActionResult> Create([Bind("Id,Sitename,Contactname,ContactPhone,ContactEmail,Capacity,UsefulLife,ProjectCost,Loan,ConsumerID")] PowerplantSite powerplantSite)
        {
            if (ModelState.IsValid)
            {
                _context.Add(powerplantSite);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ConsumerID"] = new SelectList(_context.Consumers, "ConsumerID", "ConsumerID", powerplantSite.ConsumerID);
            return(View(powerplantSite));
        }