public IActionResult Edit(string Identity, PageEditModel pageedit) { var page = myDBContent.Pages.FirstOrDefault(p => p.Identity == Identity); if (ModelState.IsValid) { page.AddTime = pageedit.AddTime; page.Identity = pageedit.Identity; page.Position = pageedit.Position; page.Age = pageedit.Age; page.Hobby = pageedit.Hobby; page.Name = pageedit.Name; page.Content = pageedit.Content; } int v = myDBContent.SaveChanges(); if (v > 0) { return(RedirectToAction("/Manage/Page/Index")); } else { ModelState.AddModelError("Identity", "修改失败!"); } return(View(page)); }//改
public IActionResult Edit(int id, NewsEditModel newsedit) { var news = myDBContent.News.Where(n => n.ID == id).FirstOrDefault(); if (ModelState.IsValid) { news.AddTime = DateTime.Now; news.Title = newsedit.Title; news.Content = newsedit.Content; } int v = myDBContent.SaveChanges(); if (v > 0) { return(Redirect("/Manage/News/Index")); } else { ModelState.AddModelError("Title", "修改失败!"); } return(View()); }
public IActionResult Index(JoinUsEdit jue) { if (ModelState.IsValid) { myDBContent.JoinUs.FirstOrDefault().Content = jue.Content; int v = myDBContent.SaveChanges(); if (v > 0) { ModelState.AddModelError("Content", "保存成功!"); } else { ModelState.AddModelError("Content", "保存失败!"); } } return(View()); }
public IActionResult Index(AboutUsAdd aud) { if (ModelState.IsValid) { myDBContent.AboutUs.FirstOrDefault().Content = aud.Content; int v = myDBContent.SaveChanges(); if (v > 0) { ModelState.AddModelError("Content", "保存成功"); } else { ModelState.AddModelError("Content", "保存失败!"); } } return(View()); }