public ActionResult CancelTicket(string id, ve_ban veBan, ve_dat_chi_tiet vdct, ghe_ngoi ghe)
        {
            try
            {
                veBan = database.ve_ban.Where(s => s.id == id).FirstOrDefault();
                vdct  = database.ve_dat_chi_tiet.Where(s => s.id == id).FirstOrDefault();
                ghe   = database.ghe_ngoi.Where(g => g.id == veBan.ghe_id).FirstOrDefault();

                ghe.da_chon      = false;
                veBan.trang_thai = "Cancelled";
                //database.ve_dat_chi_tiet.Remove(vdct);
                database.SaveChanges();
                return(RedirectToAction("TicketList"));
            }
            catch
            {
                return(Content("Error Delete!"));
            }
        }
        public ActionResult OrderTicket(string suatChieu, string dsGhe)
        {
            try
            {
                Random random = new Random();
                string chars  = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789qwertyuiopasdfghjklzxcvbnm";

                //Session["Id"] = 1;
                //Dòng trên chỉ để test code
                suat_chieu sc    = database.suat_chieu.Where(s => s.id == suatChieu).FirstOrDefault();
                ve_dat     veDat = new ve_dat();

                string[] listGhe          = dsGhe.Split(',');
                int      tienDinhDangPhim = 0;
                int      tongTien         = 0;

                if (sc.dinh_dang_phim_id != "2D")
                {
                    tienDinhDangPhim = (int)sc.dinh_dang_phim.phu_thu;
                }

                string randomChar = new string(Enumerable.Repeat(chars, 3).Select(s => s[random.Next(s.Length)]).ToArray());

                veDat.id            = Session["Id"].ToString() + "-" + sc.id + "-" + DateTime.Now.Second + randomChar;
                veDat.khach_hang_id = Convert.ToInt32(Session["Id"]);
                veDat.ngay_dat      = DateTime.Now.Date;

                database.ve_dat.Add(veDat);
                database.SaveChanges();
                string randomChr = new string(Enumerable.Repeat(chars, 5).Select(s => s[random.Next(s.Length)]).ToArray());

                foreach (var item in listGhe)
                {
                    ve_ban          veBan        = new ve_ban();
                    ve_dat_chi_tiet veDatChiTiet = new ve_dat_chi_tiet();
                    ghe_ngoi        ghe          = database.ghe_ngoi.Where(g => g.id == item).FirstOrDefault();
                    ghe.da_chon         = true;
                    veBan.id            = sc.id + "-" + ghe.id + "-" + randomChr;
                    veBan.suat_chieu_id = sc.id;
                    if (DateTime.Today.DayOfWeek == DayOfWeek.Saturday || DateTime.Today.DayOfWeek == DayOfWeek.Sunday)
                    {
                        veBan.gia_ve_id = "WEEKEND";
                        gia_ve giaVe = database.gia_ve.Where(gv => gv.id == veBan.gia_ve_id).FirstOrDefault();
                        veBan.tong__tien = tienDinhDangPhim + ghe.loai_ghe.phu_thu + giaVe.don_gia;
                        tongTien        += (int)veBan.tong__tien;
                    }
                    else
                    {
                        veBan.gia_ve_id = "WEEKDAY";
                        gia_ve giaVe = database.gia_ve.Where(gv => gv.id == veBan.gia_ve_id).FirstOrDefault();
                        veBan.tong__tien = tienDinhDangPhim + ghe.loai_ghe.phu_thu + giaVe.don_gia;
                        tongTien        += (int)veBan.tong__tien;
                    }
                    veBan.ghe_id       = ghe.id;
                    veBan.trang_thai   = "Book";
                    veBan.nhan_vien_id = database.nguoi_dung.FirstOrDefault().id;
                    //Dòng trên chỉ để test code

                    veDatChiTiet.id        = veBan.id;
                    veDatChiTiet.ve_dat_id = veDat.id;

                    database.ve_ban.Add(veBan);
                    database.ve_dat_chi_tiet.Add(veDatChiTiet);
                    database.SaveChanges();
                }
                TempData["CodeDatVe"]   = veDat.id.ToString();
                TempData["MaKhachHang"] = veDat.khach_hang_id.ToString();
                TempData["Phim"]        = sc.phim.ten.ToString();
                TempData["ThoiLuong"]   = sc.phim.thoi_luong.ToString();
                TempData["BatDau"]      = sc.gio_bat_dau.ToString();
                TempData["TongTien"]    = tongTien.ToString();

                return(Redirect("Confirmation"));
            }
            catch (Exception ex)
            {
                return(Content(ex.ToString()));
            }
        }