public ActionResult Create(TbBaiThi bt) { var session = (TestPage.Common.UserLogin)Session[TestPage.Common.CommonConstant.USER_SESSION]; var thi = new UserDao().ViewDetails(session.UserID); if (thi.Thi == true) { return(Redirect("../Exam/Annoucement")); } var dao = new BtDao(); var id = dao.Insert(bt); if (id > 0) { string wc = "/uploads/" + "WC" + session.UserID + DateTime.Now.Hour.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Year.ToString() + ".webm"; string mh = "/uploads/" + "SC" + session.UserID + DateTime.Now.Hour.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Year.ToString() + ".webm"; string at = "/uploads/" + "WC" + session.UserID + DateTime.Now.Hour.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Year.ToString() + ".wav"; var daobt = new BtDao().GetID(session.UserID).FirstOrDefault(); var stt = dao.Update(daobt.MaBaiThi, wc, mh, at); var user = new UserDao(); user.UpdateThi(session.UserID); SetAlert("Nộp thi thành công", "success"); return(RedirectToAction("Index", "Submit")); } else { ModelState.AddModelError("", "Nộp bài thi không thành công"); } SetViewBagDT(); return(View("Index")); }
public ActionResult Delete(int id) { var dao = new BtDao(); var name = dao.GetByID(id); string bt = Server.MapPath(name.DuongDanBT); string wc = Server.MapPath(name.DuongDanWC); string mh = Server.MapPath(name.DuongDanMH); string at = Server.MapPath(name.DuongDanAT); FileInfo filebt = new FileInfo(bt); FileInfo filewc = new FileInfo(wc); FileInfo filemh = new FileInfo(mh); FileInfo fileat = new FileInfo(at); if (filebt.Exists && filewc.Exists && fileat.Exists && filemh.Exists) { filebt.Delete(); filewc.Delete(); filemh.Delete(); fileat.Delete(); SetAlert("Xóa bài thi thành công", "success"); } else { ModelState.AddModelError("", "Xóa bài thi không thành công"); } dao.Delete(id); return(RedirectToAction("Index")); }
public ActionResult Index(string searchString, int page = 1, int pageSize = 20) { var dao = new BtDao(); var model = dao.ListAllPaging(searchString, page, pageSize); ViewBag.SearchString = searchString; return(View(model)); }
public ActionResult Edit() { var session = (TestPage.Common.UserLogin)Session[TestPage.Common.CommonConstant.USER_SESSION]; var exam = new BtDao().GetID(session.UserID).FirstOrDefault(); ViewBag.id = exam.MaBaiThi; ViewBag.WC = "/uploads/" + "WC" + session.UserID + DateTime.Now.Hour.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Year.ToString() + ".webm"; ViewBag.MH = "/uploads/" + "SC" + session.UserID + DateTime.Now.Hour.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Year.ToString() + ".webm"; ViewBag.AT = "/uploads/" + "WC" + session.UserID + DateTime.Now.Hour.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Year.ToString() + ".wav"; return(View(exam)); }
// // GET: /Exam/ public ActionResult Index() { var session = (TestPage.Common.UserLogin)Session[TestPage.Common.CommonConstant.USER_SESSION]; var exam = new BtDao().GetID(session.UserID).FirstOrDefault(); var thi = new UserDao().ViewDetails(session.UserID); if (thi.Thi == true) { return(RedirectToAction("../Exam/Annoucement")); } return(View()); }
public ActionResult Edit(TbBaiThi bt) { ViewBag.Files = Directory.EnumerateFiles(Server.MapPath("~/Data")); var session = (UserLogin)Session[CommonConstant.USER_SESSION]; var daobt = new BtDao().GetID(session.UserID).FirstOrDefault(); ViewBag.WC = "/uploads/" + "WC" + session.UserID + DateTime.Now.Hour.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Year.ToString() + ".webm"; ViewBag.MH = "/uploads/" + "SC" + session.UserID + DateTime.Now.Hour.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Year.ToString() + ".webm"; ViewBag.AT = "/uploads/" + "WC" + session.UserID + DateTime.Now.Hour.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Year.ToString() + ".wav"; var dao = new BtDao(); var stt = dao.Update(daobt.MaBaiThi, ViewBag.WC, ViewBag.MH, ViewBag.AT); if (stt == true) { SetAlert("Nộp video thành công", "success"); } else { ModelState.AddModelError("", "Nộp video không thành công"); } return(View("Edit")); }
public void SetViewBagDT(int?selected = null) { var dao = new BtDao(); ViewBag.MaDeThi = new SelectList(dao.ListAll(), "MaDeThi", "TenDeThi", selected); }