Esempio n. 1
0
        public ActionResult XoaDangKy(int MaHoatDong)
        {
            //kiem tra sestion Phieu dang ky hoat dong ton tai hay chua
            if (Session["PhieuDangKyHoatDong"] == null)
            {
                return(RedirectToAction("DangKyChuongTrinh"));
            }

            //kiem tra hoat dong co ton tai trong csdl hay khong
            HoatDong hd = db.HoatDongs.SingleOrDefault(n => n.MaHoatDong == MaHoatDong);

            if (hd == null)
            {
                Response.StatusCode = 404;
                return(null);
            }

            //lay list hoat dong tu sestion
            List <PhieuDangKyHoatDong> listPhieuDangKyHoatDong = LayPhieuDangKyHoatDong();

            //kiem tra hoat dong co nam trong phieu dang ky hay khong
            PhieuDangKyHoatDong hdCheck = listPhieuDangKyHoatDong.SingleOrDefault(n => n.MaHoatDong == MaHoatDong);

            if (hdCheck == null)
            {
                return(RedirectToAction("DangKyChuongTrinh"));
            }
            //xoa hoat dong da dang ky
            listPhieuDangKyHoatDong.Remove(hdCheck);

            return(RedirectToAction("XemChuongTrinh"));
        }
Esempio n. 2
0
        //them phieu dang ky (load lai trang)
        public ActionResult ThemPhieuDangKy(int MaHoatDong, string strURL)
        {
            // kiem tra hoat dong co trong csdl hay khong
            HoatDong hd = db.HoatDongs.SingleOrDefault(n => n.MaHoatDong == MaHoatDong);

            if (hd == null)
            {
                //trang duong dan khong hop le
                Response.StatusCode = 404;
                return(null);
            }

            //tao list phieu dang ky
            List <PhieuDangKyHoatDong> listPhieuDangKyHoatDong = LayPhieuDangKyHoatDong();

            //neu hoat dong da ton tai trong phieu dang ky
            PhieuDangKyHoatDong hdCheck = listPhieuDangKyHoatDong.SingleOrDefault(n => n.MaHoatDong == MaHoatDong);

            if (hdCheck != null)
            {
                hdCheck.NgayDangKy = DateTime.Now;
                return(Redirect(strURL));
            }
            PhieuDangKyHoatDong ItemPhieuDangKy = new PhieuDangKyHoatDong(MaHoatDong);

            listPhieuDangKyHoatDong.Add(ItemPhieuDangKy);
            return(Redirect(strURL));
        }