Exemplo n.º 1
0
        public async Task <IActionResult> Edit(int id, [Bind("StreetLightingId,CountLantern,Failure,LampId,LanternId,SectionId")] StreetLightings streetLightings)
        {
            if (id != streetLightings.StreetLightingId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(streetLightings);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!StreetLightingsExists(streetLightings.StreetLightingId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["LampId"]    = new SelectList(_context.Lamps, "LampId", "LampId", streetLightings.LampId);
            ViewData["LanternId"] = new SelectList(_context.Lanterns, "LanternId", "LanternId", streetLightings.LanternId);
            ViewData["SectionId"] = new SelectList(_context.Sections, "SectionId", "SectionId", streetLightings.SectionId);
            return(View(streetLightings));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Create([Bind("StreetLightingId,CountLantern,Failure,LampId,LanternId,SectionId")] StreetLightings streetLightings)
        {
            if (ModelState.IsValid)
            {
                _context.Add(streetLightings);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["LampId"]    = new SelectList(_context.Lamps, "LampId", "LampId", streetLightings.LampId);
            ViewData["LanternId"] = new SelectList(_context.Lanterns, "LanternId", "LanternId", streetLightings.LanternId);
            ViewData["SectionId"] = new SelectList(_context.Sections, "SectionId", "SectionId", streetLightings.SectionId);
            return(View(streetLightings));
        }