コード例 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("PendaftaranModelID,PenggunaModelID,WebinarModelID")] PendaftaranModel pendaftaranModel)
        {
            if (id != pendaftaranModel.PendaftaranModelID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(pendaftaranModel);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PendaftaranModelExists(pendaftaranModel.PendaftaranModelID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["PenggunaModelID"] = new SelectList(_context.PenggunaModels, "PenggunaID", "PenggunaID", pendaftaranModel.PenggunaModelID);
            ViewData["WebinarModelID"]  = new SelectList(_context.WebinarModels, "WebinarModelID", "JudulWebinar", pendaftaranModel.WebinarModelID);
            return(View(pendaftaranModel));
        }
コード例 #2
0
        public async Task <IActionResult> Create([Bind("PendaftaranModelID,PenggunaModelID,WebinarModelID")] PendaftaranModel pendaftaranModel)
        {
            if (ModelState.IsValid)
            {
                _context.Add(pendaftaranModel);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["PenggunaModelID"] = new SelectList(_context.PenggunaModels, "PenggunaID", "NamaPanjang", pendaftaranModel.PenggunaModelID);
            ViewData["WebinarModelID"]  = new SelectList(_context.WebinarModels, "WebinarModelID", "JudulWebinar", pendaftaranModel.WebinarModelID);
            return(View(pendaftaranModel));
        }