示例#1
0
        public ActionResult Edit(EditEducationViewModel model, HttpPostedFileBase File, int Id)
        {
            if (ModelState.IsValid)
            {
                var entry = Ctx.EducationBlogs.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.ProjectId = model.ProjectId;

                entry.Content = model.Content;
                entry.Title   = model.Title;

                Ctx.SaveChanges();
            }


            return(RedirectToAction("Index"));
        }
示例#2
0
        public ActionResult EditEntry(int EntryId)
        {
            var BlogEntry = Ctx.EducationBlogs.FirstOrDefault(b => b.Id == EntryId);
            //var CategoryList = Ctx.Categories.Where(c => c.CategoryType == "Formal").ToList();
            //List<string> CategoryListName = new List<string>();
            //foreach (var c in CategoryList)
            //{

            //    CategoryListName.Add(c.CategoryName);
            //}
            var blogItem1 = new EditEducationViewModel()
            {
                Id           = BlogEntry.Id,
                AttachedFile = BlogEntry.AttachedFile,
                //Category = BlogEntry.Category,
                Content = BlogEntry.Content,
                Title   = BlogEntry.Title,

                //CategoryItems = CategoryListName
            };

            return(View(blogItem1));
        }