public JsonResult UploadAjax() { foreach (string file in Request.Files) { Models.File fileModel = new Models.File(); var upload = Request.Files[file]; if (upload != null) { filename = HostingEnvironment.ApplicationPhysicalPath + "/xls/" + upload.FileName; fileModel.Path = "/xls/" + upload.FileName; fileModel.Name = upload.FileName; if (file == "file1") { fileModel.Type = 1; } else if (file == "file2") { fileModel.Type = 2; } else { fileModel.Type = 3; } Models.File f = fileRep.CreateFile(fileModel); if (file == "file1") { fileModel.Type = 1; currentFile.UpdateFile1("/xls/" + upload.FileName); currentFile.UpdateFileID1(f.Id); } else if (file == "file2") { fileModel.Type = 2; currentFile.UpdateFile2("/xls/" + upload.FileName); currentFile.UpdateFileID2(f.Id); } else { fileModel.Type = 3; currentFile.UpdateFile3("/xls/" + upload.FileName); currentFile.UpdateFileID3(f.Id); } upload.SaveAs(filename); } } if (Request.Files.Count > 1) { return(Json("файлы успешно загружены!")); } else { return(Json("файл успешно загружен!")); } }
public ActionResult Change(int id) { Models.File file = fileRep.GetFileById(id); if (file.Type == 1) { current.UpdateFile1(file.Path); current.UpdateFileID1(id); } else if (file.Type == 2) { current.UpdateFile2(file.Path); current.UpdateFileID2(id); } else { current.UpdateFile3(file.Path); current.UpdateFileID3(id); } return(View("GetNav")); }