public ActionResult AddPdf(int id, HttpPostedFileBase file, string docName, string description) { if (file.ContentLength > 0) { var f = new Wirly.web.Models.Document { Name = docName, Description = description, DocumentType = "pdf" }; var db = HttpContext.GetOwinContext().Get <WirlyDbContext>(); var project = db.Projects.Find(id); project.Documents.Add(f); db.SaveChanges(); var ext = System.IO.Path.GetExtension(file.FileName); var path = Path.Combine(Server.MapPath("~/Uploads"), f.Id.ToString() + ext); file.SaveAs(path); f.Path = string.Format("/uploads/{0}", f.Id.ToString() + ext); db.SaveChanges(); } return(RedirectToAction("Index")); }
public ActionResult AddHtml(int id, string html, string docName, string description) { var f = new Wirly.web.Models.Document { Name = docName, Description = description, Html = html, DocumentType = "html" }; var db = HttpContext.GetOwinContext().Get <WirlyDbContext>(); var project = db.Projects.Find(id); project.Documents.Add(f); db.SaveChanges(); return(RedirectToAction("Index")); }