コード例 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("IDRap,TenRap,TrangThai,IDTP")] RapModel rapModel)
        {
            if (id != rapModel.IDRap)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(rapModel);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!RapModelExists(rapModel.IDRap))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["IDTP"] = new SelectList(_context.ThanhPho, "IDTP", "IDTP", rapModel.IDTP);
            return(View(rapModel));
        }
コード例 #2
0
        public async Task <IActionResult> Edit(int id, [Bind("IdRap,TenRap,DiaChiRap,MaQuanHuyen")] RapModel rapModel)
        {
            if (id != rapModel.IdRap)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(rapModel);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!RapModelExists(rapModel.IdRap))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["MaQuanHuyen"] = new SelectList(_context.quanHuyenModels, "IdQuanHuyen", "TenQuanHuyen", rapModel.MaQuanHuyen);
            return(View(rapModel));
        }
コード例 #3
0
        public async Task <IActionResult> Create([Bind("IdRap,TenRap,DiaChiRap,MaQuanHuyen")] RapModel rapModel)
        {
            if (ModelState.IsValid)
            {
                _context.Add(rapModel);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["MaQuanHuyen"] = new SelectList(_context.quanHuyenModels, "IdQuanHuyen", "TenQuanHuyen", rapModel.MaQuanHuyen);
            return(View(rapModel));
        }
コード例 #4
0
        public async Task <IActionResult> Create([Bind("IDRap,TenRap,TrangThai,IDTP")] RapModel rapModel)
        {
            if (ModelState.IsValid)
            {
                _context.Add(rapModel);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["IDTP"] = new SelectList(_context.ThanhPho, "IDTP", "IDTP", rapModel.IDTP);
            return(View(rapModel));
        }