예제 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("PhanKhoiId,TenPhanKhoi")] PhanKhoi phanKhoi)
        {
            if (id != phanKhoi.PhanKhoiId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(phanKhoi);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PhanKhoiExists(phanKhoi.PhanKhoiId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(phanKhoi));
        }
예제 #2
0
        public async Task <IActionResult> Create([Bind("PhanKhoiId,TenPhanKhoi")] PhanKhoi phanKhoi)
        {
            if (ModelState.IsValid)
            {
                _context.Add(phanKhoi);
                await _context.SaveChangesAsync();

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