// GET: PhanSinhVienChoDotKhoaLuan/Delete/5
 public ActionResult Delete(decimal?DId, string SVId)
 {
     if (!UserManager.Authenticated)
     {
         return(RedirectToAction("Login", "Admin"));
     }
     else
     {
         if (DId == 0 || SVId == null)
         {
             return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
         }
         PhanSinhVienChoDotKhoaLuan sinhVienKhoaLuan = db.PhanSinhVienChoDotKhoaLuans.Find(DId, SVId);
         if (sinhVienKhoaLuan == null)
         {
             return(HttpNotFound());
         }
         var kh = db.DotKhoaLuans.Where(n => n.DotKhoaLuanId == DId).SingleOrDefault();
         if (kh != null)
         {
             ViewBag.IdDotKhoaLuan  = kh.DotKhoaLuanId;
             ViewBag.TenDotKhoaLuan = kh.TenDotKhoaLuan;
         }
         return(View(sinhVienKhoaLuan));
     }
 }
        public ActionResult DeleteConfirmed(decimal?DId, string SVId)
        {
            PhanSinhVienChoDotKhoaLuan phanSinhVienChoDotKhoaLuan = db.PhanSinhVienChoDotKhoaLuans.Find(DId, SVId);

            db.PhanSinhVienChoDotKhoaLuans.Remove(phanSinhVienChoDotKhoaLuan);
            db.SaveChanges();
            return(RedirectToAction("DSSV", new { DId = phanSinhVienChoDotKhoaLuan.DotKhoaLuanId }));
        }
 public ActionResult Edit([Bind(Include = "DotKhoaLuanId,SinhVienId,NgayPhan")] PhanSinhVienChoDotKhoaLuan phanSinhVienChoDotKhoaLuan)
 {
     if (ModelState.IsValid)
     {
         db.Entry(phanSinhVienChoDotKhoaLuan).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.DotKhoaLuanId = new SelectList(db.DotKhoaLuans, "DotKhoaLuanId", "TenDotKhoaLuan", phanSinhVienChoDotKhoaLuan.DotKhoaLuanId);
     ViewBag.SinhVienId    = new SelectList(db.SinhViens, "SinhVienId", "HoTen", phanSinhVienChoDotKhoaLuan.SinhVienId);
     return(View(phanSinhVienChoDotKhoaLuan));
 }
        // GET: PhanSinhVienChoDotKhoaLuan/Details/5
        public ActionResult Details(decimal id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            PhanSinhVienChoDotKhoaLuan phanSinhVienChoDotKhoaLuan = db.PhanSinhVienChoDotKhoaLuans.Find(id);

            if (phanSinhVienChoDotKhoaLuan == null)
            {
                return(HttpNotFound());
            }
            return(View(phanSinhVienChoDotKhoaLuan));
        }
        public ActionResult Create([Bind(Include = "DotKhoaLuanId,SinhVienId,NgayPhan")] PhanSinhVienChoDotKhoaLuan phanSinhVienChoDotKhoaLuan)
        {
            if (ModelState.IsValid)
            {
                db.PhanSinhVienChoDotKhoaLuans.Add(phanSinhVienChoDotKhoaLuan);
                db.SaveChanges();

                var svKh = db.PhanSinhVienChoDotKhoaLuans.Where(n => n.DotKhoaLuanId == phanSinhVienChoDotKhoaLuan.DotKhoaLuanId).ToList();
                if (svKh == null)
                {
                    return(HttpNotFound());
                }
                var kh = db.DotKhoaLuans.Where(n => n.DotKhoaLuanId == phanSinhVienChoDotKhoaLuan.DotKhoaLuanId).SingleOrDefault();
                if (kh != null)
                {
                    ViewBag.IdDotKhoaLuan  = kh.DotKhoaLuanId;
                    ViewBag.TenDotKhoaLuan = kh.TenDotKhoaLuan;
                }
                return(RedirectToAction("DSSV", new { DId = phanSinhVienChoDotKhoaLuan.DotKhoaLuanId }));
            }
            return(View(phanSinhVienChoDotKhoaLuan));
        }