Пример #1
0
        public async Task <IActionResult> Edit(int id, [Bind("LoaiTv,LoaiThanhVien")] PhanLoaiTV phanLoaiTV)
        {
            if (id != phanLoaiTV.LoaiTv)
            {
                return(BadRequest());
            }

            _context.Entry(phanLoaiTV).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PhanLoaiTVExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(View(phanLoaiTV));
        }
Пример #2
0
        public async Task <ActionResult <PhanLoaiTV> > PostPhanLoaiTV(PhanLoaiTV phanLoaiTV)
        {
            _context.PhanLoaiTVs.Add(phanLoaiTV);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetPhanLoaiTV", new { id = phanLoaiTV.LoaiTv }, phanLoaiTV));
        }
Пример #3
0
        public async Task <IActionResult> Create([Bind("LoaiTv,LoaiThanhVien")] PhanLoaiTV phanLoai)
        {
            if (ModelState.IsValid)
            {
                _context.Add(phanLoai);
                await _context.SaveChangesAsync();

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