public ActionResult SignUp(DangKi model)
        {
            tbl_thongtincanhan ttcn = new tbl_thongtincanhan();
            tbl_taikhoan       tk   = new tbl_taikhoan();

            Func_ThongTinCaNhan f_ttcn = new Func_ThongTinCaNhan();
            Func_TaiKhoan       f_tk   = new Func_TaiKhoan();

            ttcn.ten      = model.ten;
            ttcn.sdt      = model.sdt;
            ttcn.email    = model.email;
            ttcn.ngaysinh = model.ngaysinh;
            ttcn.gioitinh = model.gioitinh;
            if (ttcn.gioitinh == "Nam")
            {
                ttcn.anhdaidien = "anhNam.png";
            }
            else
            {
                ttcn.anhdaidien = "anhNu.png";
            }
            ttcn.diachi = model.diachi;
            f_ttcn.Insert(ttcn);


            tk.id_q        = 3;
            tk.tentaikhoan = model.tentaikhoan;
            tk.matkhau     = model.matkhau;
            tk.id_ttcn     = ttcn.id;
            tk.trangthai   = true;
            f_tk.Insert(tk);


            return(Redirect("/Home/Index"));
        }
        // Xóa theo key
        public int?Delete(int id)
        {
            tbl_taikhoan dbEntry = context.tbl_taikhoan.Find(id);

            if (dbEntry == null)
            {
                return(null);
            }

            context.tbl_taikhoan.Remove(dbEntry);
            context.SaveChanges();
            return(id);
        }
        // Thêm 1 đối tượng
        public int?Insert(tbl_taikhoan model)
        {
            tbl_taikhoan dbEntry = context.tbl_taikhoan.Find(model.id);

            if (dbEntry != null)
            {
                return(null);
            }

            context.tbl_taikhoan.Add(model);
            context.SaveChanges();
            return(model.id);
        }
        // GET: GioHang
        public ActionResult Index()
        {
            if (Session["userLogin"] == null)
            {
                return(Redirect("~/admin/Login/Index"));
            }
            Func_TaiKhoan getid = new Func_TaiKhoan();
            //UserLogin user = (UserLogin)Session["userLogin"];
            tbl_taikhoan tk = getid.getTaiKhoan((string)Session["userLogin"]);

            ViewBag.iduser = tk.id;
            return(View());
        }
        public ActionResult NecessaryInfomation()
        {
            if (Session["userLogin"] == null)
            {
                return(Redirect("~/admin/Login/Index"));
            }
            else
            {
                var xuly = new Func_TaiKhoan();

                ViewBag.user = xuly.getThongTin((int)Session["IDTinhTrang"]);
                tbl_taikhoan tk = xuly.getTaiKhoan((string)Session["userLogin"]);
                ViewBag.idBook = tk.id;

                return(View());
            }
        }
        // Sửa dữ liệu
        public int?Update(tbl_taikhoan model)
        {
            tbl_taikhoan dbEntry = context.tbl_taikhoan.Find(model.id);

            if (dbEntry == null)
            {
                return(null);
            }

            dbEntry.id_q        = model.id_q;
            dbEntry.id_ttcn     = model.id_ttcn;
            dbEntry.matkhau     = model.matkhau;
            dbEntry.tentaikhoan = model.tentaikhoan;
            dbEntry.trangthai   = model.trangthai;

            context.SaveChanges();

            return(model.id);
        }
        public ActionResult DonHang(string giatien, string sdt, string ngaymua, string diachigiaohang)
        {
            var          xuly  = new Func_TaiKhoan();
            tbl_taikhoan tk    = xuly.getTaiKhoan((string)Session["userLogin"]);
            var          model = new tbl_dondathang();

            model.ngaylap = Convert.ToDateTime(ngaymua);
            model.tonggia = Convert.ToInt32(giatien);
            model.diachi  = diachigiaohang;
            model.sdt     = sdt;
            db.tbl_dondathang.Add(model);
            db.SaveChanges();

            List <tbl_chitietdonhang> a = new Func_ChiTietDonHang().getSanPhamGioHang(tk.id);

            foreach (tbl_chitietdonhang x in a)
            {
                x.id_tinhtrang = 2;
                var update = new Func_ChiTietDonHang().Update(x);
            }
            return(Redirect("/GioHang/Index"));
        }
        // Trả về 1 đối tượng khi biết khóa
        public tbl_taikhoan FindEntity(int id)
        {
            tbl_taikhoan dbEntry = context.tbl_taikhoan.Find(id);

            return(dbEntry);
        }