public ActionResult DeleteConfirmed(int id) { Attchment attchment = db.Attchments.Find(id); db.Attchments.Remove(attchment); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "Id,AssetEntryId,File")] Attchment attchment) { if (ModelState.IsValid) { db.Entry(attchment).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.AssetEntryId = new SelectList(db.AssetEntries, "Id", "AssetId", attchment.AssetEntryId); return(View(attchment)); }
// GET: Attchments/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Attchment attchment = db.Attchments.Find(id); if (attchment == null) { return(HttpNotFound()); } return(View(attchment)); }
// GET: Attchments/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Attchment attchment = db.Attchments.Find(id); if (attchment == null) { return(HttpNotFound()); } ViewBag.AssetEntryId = new SelectList(db.AssetEntries, "Id", "AssetId", attchment.AssetEntryId); return(View(attchment)); }
public JsonResult AttechmentSaveApi(AttchmentViewModel attchmentVm) { byte[] file = System.IO.File.ReadAllBytes(attchmentVm.File); ModelState.Remove("Id"); if (ModelState.IsValid) { //byte[] uploadedFile = new byte[attchmentVm.File.InputStream.Length]; //attchmentVm.File.InputStream.Read(uploadedFile, 0, uploadedFile.Length); var attchment = new Attchment() { AssetEntryId = attchmentVm.AssetEntryId, File = file }; int count = _attachmentManager.Add(attchment); return(Json(count, JsonRequestBehavior.AllowGet)); } return(Json(0, JsonRequestBehavior.AllowGet)); }