public async Task <ActionResult> DeleteConfirmed(int id) { DigitalPhotograph digitalphotograph = await db.DigitalPhotographs.FindAsync(id); db.DigitalPhotographs.Remove(digitalphotograph); await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
public async Task <ActionResult> Edit([Bind(Include = "Id,SpecimenId,ScanDate,FileName,OriginalFileName,MimeType,LastModified,Process,CopyrightInfo,IsVisible")] DigitalPhotograph digitalphotograph) { if (ModelState.IsValid) { db.Entry(digitalphotograph).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewBag.SpecimenId = new SelectList(db.Specimens, "Id", "AuthorCatalogationCode", digitalphotograph.SpecimenId); return(View(digitalphotograph)); }
// GET: /DigitalPhotograph/Details/5 public async Task <ActionResult> Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } DigitalPhotograph digitalphotograph = await db.DigitalPhotographs.FindAsync(id); if (digitalphotograph == null) { return(HttpNotFound()); } return(View(digitalphotograph)); }
// GET: /DigitalPhotograph/Edit/5 public async Task <ActionResult> Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } DigitalPhotograph digitalphotograph = await db.DigitalPhotographs.FindAsync(id); if (digitalphotograph == null) { return(HttpNotFound()); } ViewBag.SpecimenId = new SelectList(db.Specimens, "Id", "AuthorCatalogationCode", digitalphotograph.SpecimenId); return(View(digitalphotograph)); }
public async Task <ActionResult> Create(SpecimenPhotoUploadModel model) { if (ModelState.IsValid) { var returnModel = new DigitalPhotographPostUploadModel(); foreach (var photo in model.Photos) { var fileName = Guid.NewGuid().ToString() + "_" + photo.FileName; var dPhoto = new DigitalPhotograph { SpecimenId = model.SpecimenId, FileName = fileName }; // Save the file and the smaller versions. var completePath = Server.MapPath("~/App_Data/Uploads/Photos/"); Directory.CreateDirectory(completePath); photo.SaveAs(completePath + fileName); FileUploadHelper.GenerateVersions(completePath + fileName); returnModel.UploadedItems.Add(new DigitalPhotographUploadItem { DigitalPhotograph = dPhoto }); db.DigitalPhotographs.Add(dPhoto); } await db.SaveChangesAsync(); if (Request.IsAjaxRequest()) { return(PartialView("PostUpload", returnModel)); } return(View("PostUpload", returnModel)); } return(View(model)); }
public async Task <ActionResult> DeleteConfirmed(int id) { DigitalPhotograph digitalPhotograph = await db.DigitalPhotographs.FindAsync(id); var fullPath = Server.MapPath("~/App_Data/Uploads/Photos/" + digitalPhotograph.FileName); // Remove file from the disk. if (System.IO.File.Exists(fullPath + "_thumb.jpg")) { System.IO.File.Delete(fullPath + "_thumb.jpg"); } if (System.IO.File.Exists(fullPath + "_large.jpg")) { System.IO.File.Delete(fullPath + "_large.jpg"); } db.DigitalPhotographs.Remove(digitalPhotograph); await db.SaveChangesAsync(); return(RedirectToAction("Details", "Specimens", new { id = digitalPhotograph.SpecimenId })); }