Exemple #1
0
 public ActionResult UploadEdition(HttpPostedFileBase edition, int id)
 {
     if (edition != null)
     {
         var fileName = Path.GetFileNameWithoutExtension(edition.FileName);
         //取得版本號
         var editioncount = _fileServices.GetEditionCount(id);
         var type = Path.GetExtension(edition.FileName);
         var pathName = fileName + "_" + editioncount + type;
         var path = Path.Combine(Server.MapPath("~/FileUpload"), pathName);
         var size = edition.ContentLength;
         // 將檔案存入資料庫
         _fileServices.Update(id, fileName, editioncount, type, path, size);
         //將檔案存放至實體路徑
         edition.SaveAs(path);
     }
     //更新版本列表
     List<Model.File> editionList = _fileServices.GetEdition(id);
     EditionView editionListView = new EditionView();
     editionListView.fileList = new List<FileView>();
     editionListView.fileList = Mapper.Map<List<FileView>>(editionList);
     foreach (var item in editionListView.fileList)
     {
         item.UserName = _userServices.GetNameByAccount(item.Account);
     }
     ViewBag.id = id;
     //更新部分頁面
     return PartialView("_EditionPartial", editionListView);
 }
Exemple #2
0
 public ActionResult Edition(int id)
 {
     //根據檔案編號取得所有版本
     List<Model.File> editionList = _fileServices.GetEdition(id);
     EditionView editionListView = new EditionView();
     editionListView.fileList = new List<FileView>();
     editionListView.fileList = Mapper.Map<List<FileView>>(editionList);
     foreach (var item in editionListView.fileList)
     {
         item.UserName = _userServices.GetNameByAccount(item.Account);
     }
     ViewBag.id = id;
     return View(editionListView);
 }