//private ActionResult DeleteArtifact(string fileName) //{ // DeleteFromFileSystem(fileName); // //remove from database // DeleteArtifactsByFileName(fileName); // Artifact artifact = db.Artifact.Find(fileName); // //db.Artifact.Remove().FileName(fileName); // //db.Artifact. // //db.SaveChanges(); //} //[Authorize] //[ValidateAntiForgeryToken] public ActionResult DeleteArtifact(string fileName) { // ensure at least one row exists // by testing for the generic person row for this filename Artifact artifact = db.Artifact.Find(fileName, genericPersonName); // Delete the row from the database if (PersonDB.DelNamesByFile(fileName) == true) { ; } //build the paths to the file names string smallImageFilePath = Path.Combine(Server.MapPath("~/photoprowess/images/demo/gallery/") + "ThumbSize" + (artifact.FileName)); string largeImageFilePath = Path.Combine(Server.MapPath("~/photoprowess/images/demo/gallery/") + (artifact.FileName)); //Delete both the file and it's associated thumbnail from the FileSystem //If both file names exist, delete them from the file system if (System.IO.File.Exists(smallImageFilePath) && (System.IO.File.Exists(largeImageFilePath))) { try { System.IO.File.Delete(smallImageFilePath); System.IO.File.Delete(largeImageFilePath); } catch (System.IO.DirectoryNotFoundException e) { TempData["ReturnData"] = " Delete exception. DirectoryNotFoundException. The Details follow: " + e.ToString(); return(RedirectToAction("Index")); } catch (System.IO.IOException e) { TempData["ReturnData"] = " Delete exception. IOException. The Details follow: " + e.ToString(); return(RedirectToAction("Index")); } catch (Exception ex) { TempData["ReturnData"] = " Delete exception. Exception. The Details follow: " + ex.ToString(); return(RedirectToAction("Index")); } } else { TempData["ReturnData"] = " File Delete exception: Either File " + smallImageFilePath + " Or File " + largeImageFilePath + " was not found. As a result, neither File delete was attempted."; return(RedirectToAction("Index")); } TempData["ReturnData"] = "The following File was deleted: " + artifact.FileName; return(RedirectToAction("Index")); }
//[Authorize] //[ValidateAntiForgeryToken] //public ActionResult FileAssociate([Bind(Include = "FileName,Name,ArtifactType,HeadStone,Description")]Artifact artifact) public ActionResult FileAssociate(List <BomanGen.Models.ArtifactModel> list) { ViewBag.Message = "It's Test 1 2 3 Time"; string currFileName = Session["currentFileProcessed"].ToString(); // Retrieve and temporarily hold the generic row in an Artifact Model class var genericArtifactRow = db.Artifact.Find(currFileName, genericPersonName); // Delete all database rows for this fileName // in case the user de-selected any of them if (PersonDB.DelNamesByFile(currFileName) == true) { ; } // Re-Add the Generic Person database row since it has to exist PersonDB.AddNameToArtifacts(genericArtifactRow); /* bool trueOrFalse = PersonDB.DelNamesByFile(currFileName); */ int ttlNumOfNames = list.Count; for (int x = 0; x < ttlNumOfNames; x++) { if (list[x].IfChecked == true) { Artifact currArtifact = new Artifact(); //var myRow = db.Artifact.ToArray(); //var genericRow = db.Artifact.Find(currFileName); currArtifact.FileName = currFileName; currArtifact.Name = list[x].Name; currArtifact.HeadStone = genericArtifactRow.HeadStone; currArtifact.Description = genericArtifactRow.Description; currArtifact.ArtifactType = genericArtifactRow.ArtifactType; //BomanGen.Models.Artifact currArtifact; PersonDB.AddNameToArtifacts(currArtifact); } } TempData["ReturnData"] = "The following Artifact or Photo was Updated successfully: " + currFileName; return(View(list)); }