public ActionResult UploadFileTaiLieu(int id, HttpPostedFileBase fileTaiLieu)
 {
     using (var kHKTKhoaHocKiThuatRepository = new KHKTKhoaHocKiThuatService())
     {
         try
         {
             if (fileTaiLieu.ContentLength > 0)
             {
                 //string filename = Path.GetFileName(fileTaiLieu.FileName);
                 KhoaHocKiThuat khoaHocKiThuat = kHKTKhoaHocKiThuatRepository.GetKhoaHocKiThuatById(id);
                 if (khoaHocKiThuat == null)
                 {
                     return(Json("failed"));
                 }
                 string filename = String.Format("{0:00}", khoaHocKiThuat.LinhVucId) + '-' + khoaHocKiThuat.Id.ToString() + Path.GetExtension(fileTaiLieu.FileName);
                 string _path    = Path.Combine(Server.MapPath("~/UploadedFiles/KhoaHocKiThuat"), filename);
                 fileTaiLieu.SaveAs(_path);
                 kHKTKhoaHocKiThuatRepository.UpdateFileTaiLieuKhoaHocKiThuat(id, filename.Trim());
                 return(Json(new ReturnFormat(200, "success", null), JsonRequestBehavior.AllowGet));
             }
             else
             {
                 kHKTKhoaHocKiThuatRepository.DeleteKHKTById(id);
                 return(Json("failed"));
             }
         }
         catch
         {
             kHKTKhoaHocKiThuatRepository.DeleteKHKTById(id);
             return(Json("failed"));
         }
     }
 }
        public ActionResult TaiFileTaiLieuKHKT(int id)
        {
            Account account = (Account)Session[Utils.Constant.MANAGER_SESSION];

            if (account == null)
            {
                return(RedirectToRoute("login"));
            }
            using (var kHKTKhoaHocKiThuatRepository = new KHKTKhoaHocKiThuatService())
            {
                KhoaHocKiThuat khoaHocKiThuat = kHKTKhoaHocKiThuatRepository.GetKhoaHocKiThuatById(id);
                string         filePath       = System.Web.HttpContext.Current.Server.MapPath("~/UploadedFiles/KhoaHocKiThuat/" + khoaHocKiThuat.FileTaiLieu.Trim());
                if (khoaHocKiThuat.FileTaiLieu.Contains(".docx"))
                {
                    return(File(filePath, "application/vnd.openxmlformats-officedocument.wordprocessingml.document", khoaHocKiThuat.FileTaiLieu));
                }
                else if (khoaHocKiThuat.FileTaiLieu.Contains(".xlsx"))
                {
                    return(File(filePath, "application/vnd.ms-excel", khoaHocKiThuat.FileTaiLieu));
                }
                return(File(filePath, "application/msword", khoaHocKiThuat.FileTaiLieu));
            }
        }