示例#1
0
        public async Task <IActionResult> Edit(int id, Seraphin seraphin)
        {
            if (id != seraphin.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(seraphin);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SeraphinExists(seraphin.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(seraphin));
        }
示例#2
0
        // GET: Seraphins/Create
        public IActionResult Create(int id)
        {
            Seraphin seraphin = new Seraphin();

            seraphin.IdStation = id;

            return(View(seraphin));
        }
示例#3
0
        public async Task <IActionResult> Create(Seraphin seraphin)
        {
            if (ModelState.IsValid)
            {
                seraphin.Station = _context.Stations.Find(seraphin.IdStation);
                seraphin.Id      = 0;
                _context.Add(seraphin);

                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(seraphin));
        }