public async Task <ActionResult <HangGheModel> > PostHangGheModel(HangGheModel hangGheModel) { _context.tb_HangGhe.Add(hangGheModel); await _context.SaveChangesAsync(); return(CreatedAtAction("GetHangGheModel", new { id = hangGheModel.Id }, hangGheModel)); }
public async Task <IActionResult> PutHangGheModel(int id, HangGheModel hangGheModel) { if (id != hangGheModel.Id) { return(BadRequest()); } _context.Entry(hangGheModel).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!HangGheModelExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
// GET: Admin/HangGhe public async Task <IActionResult> Index(int?id, int?TenPhong) { ViewBag.ListPhong = (from a in _context.tb_CumRap join b in _context.tb_RapPhim on a.Id equals b.MaCumRap join c in _context.tb_Phong on b.Id equals c.MaRap where a.TrangThai == true where b.TrangThai == true where c.TrangThai == true select new { Id = c.Id, Value = c.TenPhong + " - " + b.TenRap + " - " + a.TenCum }).ToList(); HangGheModel hangghe = null; if (id != null) { hangghe = await _context.tb_HangGhe.FirstOrDefaultAsync(n => n.Id == id); } if (TenPhong != null) { ViewBag.ListHangGhe = (from m in _context.tb_HangGhe where m.MaPhong == TenPhong select m).ToList(); } return(View(hangghe)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,TenHang,MaPhong,TrangThai")] HangGheModel hangGheModel) { ViewBag.ListPhong = _context.tb_Phong.Where(m => m.TrangThai == true).ToList(); if (id != hangGheModel.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(hangGheModel); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!HangGheModelExists(hangGheModel.Id)) { return(NotFound()); } else { throw; } } } return(RedirectToAction("Index", "HangGhe")); }
public async Task <IActionResult> Create(int soluong, int idphong) { ViewBag.ListPhong = _context.tb_Phong.Where(m => m.TrangThai == true).ToList(); char[] ch = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O' }; for (int i = 0; i < soluong; i++) { HangGheModel hg = new HangGheModel(); hg.TenHang = ch[i].ToString(); hg.MaPhong = idphong; hg.TrangThai = true; _context.Add(hg); } await _context.SaveChangesAsync(); return(RedirectToAction("Index", "Ghe")); }