public ActionResult Delete(Document d) { //var f = GetFile(_db.GetById(d.Id).FilePath); _db.Delete(d); _db.Commit(); return PartialView("ListAll", _db.GetAll()); }
public ActionResult Create(Document d) { if (!ModelState.IsValid) { ViewData["errors"] = ModelState.Values.SelectMany(v => v.Errors); return PartialView(d); } foreach (string f in Request.Files) { HttpPostedFileBase file = Request.Files[f]; if (file.ContentLength > 0) { string filePath = Path.Combine(HttpContext.Server.MapPath("/Content/Uploads") , Path.GetFileName(file.FileName)); file.SaveAs(filePath); d.FilePath = "/Pdf/" + Path.GetFileNameWithoutExtension(file.FileName); } } _db.Add(d); _db.Commit(); return PartialView("ListAll", _db.GetAll()); }
public void Update(Document d) { Document doc = GetById(d.Id); doc.Title = d.Title; doc.Authors = d.Authors; doc.Description = d.Description; doc.Rating = d.Rating; }
public ActionResult Edit(Document d) { if (!ModelState.IsValid) { return PartialView("Edit", d); } _db.Update(d); _db.Commit(); return PartialView("Details", d); }
public bool Delete(Document d) { if (d != null) { //_context.ObjectStateManager.ChangeObjectState(d, System.Data.EntityState.Deleted); _context.DeleteObject(GetById(d.Id)); //_context.SaveChanges(); return true; } return false; }
/// <summary> /// Deprecated Method for adding a new object to the Document EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToDocument(Document document) { base.AddObject("Document", document); }
/// <summary> /// Create a new Document object. /// </summary> /// <param name="id">Initial value of the Id property.</param> /// <param name="filePath">Initial value of the FilePath property.</param> public static Document CreateDocument(global::System.Int32 id, global::System.String filePath) { Document document = new Document(); document.Id = id; document.FilePath = filePath; return document; }
public void Add(Document d) { _context.Document.AddObject(d); }