public ActionResult EditInformal(EditInformalEntryViewModel model, HttpPostedFileBase File, int Id) { if (ModelState.IsValid) { var entry = Ctx.InformalBlogEntries.FirstOrDefault(b => b.Id == Id); var Filestring = FileUpload(File); if (Filestring != null) { entry.AttachedFile = Filestring; } else { entry.AttachedFile = model.AttachedFile; } entry.Category = model.Category; entry.Content = model.Content; entry.Title = model.Title; Ctx.SaveChanges(); } return(RedirectToAction("Index", "InformalBlog")); }
public ActionResult EditInformalEntry(int EntryId) { var BlogEntry = Ctx.InformalBlogEntries.FirstOrDefault(b => b.Id == EntryId); var CategoryList = Ctx.Categories.Where(c => c.CategoryType == "Informal").ToList(); List <string> CategoryListName = new List <string>(); foreach (var c in CategoryList) { CategoryListName.Add(c.CategoryName); } var InformalBlogItem = new EditInformalEntryViewModel() { Id = BlogEntry.Id, AttachedFile = BlogEntry.AttachedFile, Category = BlogEntry.Category, Content = BlogEntry.Content, Title = BlogEntry.Title, CategoryItems = CategoryListName }; return(View(InformalBlogItem)); }