public ActionResult ConfirmDelete(FormCollection fcNotUsed, int id) { FileBusinessLayer fbl = new FileBusinessLayer(); FileDB file = fbl.GetFile(id); if (file == null) { return(HttpNotFound()); } //System.IO.File.Delete(file.FilePath); fbl.SaveFile(file, "delete"); return(RedirectToAction("Index")); }
public ActionResult Delete(FormCollection fcNotUsed, int id) { FileBusinessLayer fbl = new FileBusinessLayer(); FileDB file = fbl.GetFile(id); if (file == null) { return(HttpNotFound()); } fbl.SaveFile(file, "mark delete"); return(RedirectToAction("Index")); }
public ActionResult Delete(FormCollection fcNotUsed, int id) { FileBusinessLayer fbl = new FileBusinessLayer(); FileDB file = fbl.GetFile(id); if (file == null) { return(HttpNotFound()); } file.ModifiedTime = DateTime.Now; file.isDelete = true; fbl.SaveFile(file); return(RedirectToAction("Index")); }
public ActionResult Edit() { int FileId = int.Parse(Request["FileId"]); System.Diagnostics.Debug.Write(FileId); string FileName = Request["FileName"]; int FileVersion = int.Parse(Request["FileVersion"]); string FileContent = Request["FileContent"]; FileDB file = new FileDB(); file.FileId = FileId; file.FileName = FileName; file.FilePath = fileTime + "_" + FileVersion + "_" + FileName; file.Creater = User.Identity.Name; file.Version = FileVersion; FileStream fs = new FileStream(Path.Combine(_uploadsFolder, file.FilePath), FileMode.Create); StreamWriter sw = new StreamWriter(fs); sw.Write(FileContent); sw.Flush(); sw.Close(); fs.Close(); FileBusinessLayer fbl = new FileBusinessLayer(); fbl.SaveFile(file, "modify"); var result = new { err = false, message = "no err" }; return(Json(result)); /* * catch * { * var result = new { err = true, message = "save file err" }; * return Json(result); * } * */ }
public ActionResult SaveFile(string fileName, HttpPostedFileBase uploadFile) { if (uploadFile != null && fileName != null) { FileDB file = new FileDB(); file.FileName = fileName; file.Creater = User.Identity.Name; file.FilePath = uploadFile.FileName; uploadFile.SaveAs(Path.Combine(_uploadsFolder, file.FilePath)); FileBusinessLayer fbl = new FileBusinessLayer(); fbl.SaveFile(file, "upload"); return(RedirectToAction("Index")); } else { FileViewModel fvm = new FileViewModel(); fvm.FileName = fileName; return(View("Upload", fvm)); } }
public ActionResult SaveFile(FileDB file, string BtnSubmit, HttpPostedFileBase UploadFile) { if (UploadFile != null) { switch (BtnSubmit) { case "Save File": file.FilePath = Path.Combine(_uploadsFolder, UploadFile.FileName); UploadFile.SaveAs(file.FilePath); file.Creater = "Admin"; file.UploadTime = DateTime.Now; file.ModifiedTime = DateTime.Now; file.Version = 1; file.isDelete = false; FileBusinessLayer fbl = new FileBusinessLayer(); fbl.SaveFile(file); return(RedirectToAction("Index")); //if (ModelState.IsValid) { } //else //{ // CreateFileViewModel cfvm = new CreateFileViewModel(); // cfvm.FileName = file.FileName; // return View("CreateFile", cfvm); //} case "Cancel": return(RedirectToAction("Index")); default: return(RedirectToAction("CreateFile", new CreateFileViewModel())); } } return(Content("Upload Error! File is empty")); }