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 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 int Insert(TbBaiThi entity) { db.TbBaiThis.Add(entity); db.SaveChanges(); return(entity.MaBaiThi); }