public ActionResult AddPhongChieu(phong_chieu _phong) { if (!AuthCheck("admin")) { return(RedirectToAction("Index")); } try { _phong.so_luong_cot = 10; _phong.so_luong_day = 10; db.phong_chieu.Add(_phong); #region Add_ghế List <ghe_ngoi> ds_ghe = new List <ghe_ngoi>(); string[] col = new string[] { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J" }; for (int i = 1; i < 11; i++) { for (int j = 1; j < 11; j++) { ghe_ngoi ghe = new ghe_ngoi(); ghe.da_chon = false; ghe.phong_chieu_id = _phong.id; ghe.vi_tri_day = i; ghe.vi_tri_cot = col[j - 1]; ghe.id = ghe.phong_chieu_id + "_" + ghe.vi_tri_day + ghe.vi_tri_cot; ghe.loai_ghe_id = "NORMAL"; if ((i >= 3 && i <= 7) && (j >= 4 && j <= 7)) { ghe.loai_ghe_id = "VIP"; } ds_ghe.Add(ghe); } } foreach (ghe_ngoi _ghe in ds_ghe) { db.ghe_ngoi.Add(_ghe); } #endregion Add_ghế db.SaveChanges(); return(RedirectToAction("QLPhongChieu")); } catch (Exception e) { ViewBag.Error = e.ToString(); return(View("~/Views/QLHome/Error.cshtml")); } }
public ActionResult DeletePhongChieu(int id) { if (!AuthCheck("admin")) { return(RedirectToAction("Index")); } try { phong_chieu phong_Chieu = db.phong_chieu.Where(item => item.id == id).FirstOrDefault(); List <ghe_ngoi> ghe_Ngoi = db.ghe_ngoi.Where(item => item.phong_chieu_id == id).ToList(); foreach (ghe_ngoi ghe in ghe_Ngoi) { db.ghe_ngoi.Remove(ghe); } db.phong_chieu.Remove(phong_Chieu); db.SaveChanges(); return(RedirectToAction("QLPhongChieu")); } catch (Exception e) { ViewBag.Error = e.ToString(); return(View("~/Views/QLHome/Error.cshtml")); } }