public ActionResult DocEdit(HttpPostedFileBase uploadFile, DocMgrVM vm, int id) { if (ModelState.IsValid) { HelpDoc doc = db.HelpDocs.Single(p => p.DocId == id); doc.DocName = vm.HelpDoc.DocName; doc.Description = vm.HelpDoc.Description; doc.DocInfo = vm.HelpDoc.DocInfo; doc.IsVisible = vm.HelpDoc.IsVisible; if (uploadFile != null && uploadFile.ContentLength != 0) { using (MemoryStream ms = new MemoryStream()) { uploadFile.InputStream.CopyTo(ms); byte[] fileData = ms.GetBuffer(); doc.Filename = uploadFile.FileName; doc.ContentLength = uploadFile.ContentLength; doc.ContentType = uploadFile.ContentType; doc.Data = fileData; } } db.SaveChanges(); return RedirectToAction("DocList", new { id = vm.HelpDoc.MenuId }); } vm.HelpDoc = db.HelpDocs.Single(p => p.DocId == id); return View(vm); }
public ActionResult DocList(int id) { DocMgrVM vm = new DocMgrVM(); vm.HelpMenu = db.HelpMenus.Single(p => p.MenuId == id); vm.HelpDocs = db.HelpDocs.Where(p => p.MenuId == id); return View(vm); }
public ActionResult DocEdit(int id) { DocMgrVM vm = new DocMgrVM(); vm.HelpDoc = db.HelpDocs.Single(p => p.DocId == id); return View(vm); }