public ActionResult GetFile(string filetype, string id) { var FileContext = _context.GetContext(filetype); dynamic file = FileContext.Find(id); var json = new JsonResult(); json.JsonRequestBehavior = JsonRequestBehavior.AllowGet; if (file != null) { json.Data = file; } FileTypeDetails fileDetails = manager.FileQuery(filetype); FileModelFileTypeView data = new FileModelFileTypeView(file, fileDetails, false); return(View("~/Views/FileView/FileShow.cshtml", data)); }
public ActionResult Upload() { // Initialize Context & Path to files var ctx = this.HttpContext; var root = ctx.Server.MapPath("~/"); // Receive file & meta data var provider = new MultipartFormDataStreamProvider(root); var files = Request.Files; var input_file = files[0]; string filetype = Request.Form["type"]; var filesPath = $"{root}/Resources/userfiles/{filetype}/"; // Initialize File var FileModelType = manager.GetModelType(filetype); var FileModelObject = Activator.CreateInstance(FileModelType, input_file, Request); dynamic File = Convert.ChangeType(FileModelObject, FileModelType); // Initialize DB Context var FileContext = _context.GetContext(filetype); // Save File to disk & DB input_file.SaveAs($"{filesPath + File.Name + "." + File.Extension}"); FileContext.Add(File); // Save DB Changes _context.SaveChanges(); FileTypeDetails fileDetails = manager.FileQuery(filetype); FileModelFileTypeView data = new FileModelFileTypeView(File, fileDetails, true); return(View("~/Views/FileView/FileShow.cshtml", data)); }
public ActionResult Index(string filetype) { FileTypeDetails FileDetails = manager.FileQuery(RouteData.Values["filetype"].ToString()); return(View("~/Views/FileUpload/UploadView.cshtml", FileDetails)); }
public FileModelFileTypeView(dynamic file, FileTypeDetails details, bool ownerView) { File = file; FileTypeDetails = details; OwnerView = ownerView; }