コード例 #1
0
        public ActionResult DeleteConfirmed(int id)
        {
            Attchment attchment = db.Attchments.Find(id);

            db.Attchments.Remove(attchment);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #2
0
 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));
 }
コード例 #3
0
        // 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));
        }
コード例 #4
0
        // 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));
        }
コード例 #5
0
        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));
        }