public ActionResult File(HttpPostedFileBase file, int idlh) { //try // if (file.ContentLength > 0) { var lh = new LopHocDAO().GetByID(idlh); string _FileName = Path.GetFileName(file.FileName); string _path = Path.Combine(Server.MapPath("~/Content/img/"), _FileName); file.SaveAs(_path); int fileSize = file.ContentLength; int Size = fileSize / 1000000; var dao = new TaiLieuDAO(); var tailieu = new TaiLieu(); tailieu.ten = _FileName; tailieu.FileSize = Size; tailieu.link = _path; tailieu.idLH = lh.ID; tailieu.thoiGian = DateTime.Now; tailieu.idTK = lh.Giangvien.TaiKhoan.iD; tailieu.idKN = 5; dao.Insert(tailieu); } ViewBag.Message = "File Uploaded Successfully!!"; return(RedirectToAction("File")); //} //catch //{ // ViewBag.Message = "File upload failed!!"; // return RedirectToAction("File"); //} }
public ActionResult Zoom(string ten, string trangthai, string ma, int idlh, string thoigian) { var lh = new LopHocDAO().GetByID(idlh); var dao = new TaiLieuDAO(); var tailieu = new TaiLieu(); tailieu.ten = ten; tailieu.link = ma; tailieu.moTa = trangthai; tailieu.idLH = lh.ID; tailieu.idTK = lh.Giangvien.TaiKhoan.iD; //tailieu.idKN = 6; try { tailieu.thoiGian = DateTime.Parse(thoigian); dao.Insert(tailieu); TempData["testmsg"] = "Tạo phòng ZOOM thành công."; } catch (Exception ex) { TempData["testmsg"] = "Lỗi tạo phòng ZOOM: " + ex.Message; } return(RedirectToAction("ChiTiet/" + lh.ID, "QLLopHoc")); }
public ActionResult Doc(string ten, string link, int idlh) { var lh = new LopHocDAO().GetByID(idlh); var dao = new TaiLieuDAO(); var tailieu = new TaiLieu(); tailieu.ten = ten; tailieu.link = link; tailieu.idLH = lh.ID; tailieu.idTK = lh.Giangvien.TaiKhoan.iD; tailieu.idKN = 3; tailieu.thoiGian = DateTime.Now; dao.Insert(tailieu); return(RedirectToAction("Doc/" + lh.ID, "Doc")); }
public ActionResult UploadAudio(HttpPostedFileBase fileupload, int idlh) { if (fileupload != null) { var lh = new LopHocDAO().GetByID(idlh); string fileName = Path.GetFileName(fileupload.FileName); int fileSize = fileupload.ContentLength; int Size = fileSize / 1000000; fileupload.SaveAs(Server.MapPath("~/" + fileName)); var dao = new TaiLieuDAO(); var tailieu = new TaiLieu(); tailieu.ten = fileName; tailieu.FileSize = Size; tailieu.link = "~/" + fileName; tailieu.idLH = lh.ID; tailieu.idTK = lh.Giangvien.TaiKhoan.iD; tailieu.idKN = 1; dao.Insert(tailieu); } return(RedirectToAction("UploadAudio")); }