コード例 #1
0
        public ActionResult EditGuide(Guid guideid, Guidelang lang, Guid Uuid)
        {
            Guide guide = guideService.GetByID(guideid);

            guide.Uuid = Guid.NewGuid();
            guideService.Update(guide);
            guideService.SaveChanges();
            if (TryUpdateModel(lang, new string[] { "Title", "Contents" }) && ModelState.IsValid)
            {
                guidelangService.Update(lang);
                guidelangService.SaveChanges();

                return(RedirectToAction("Guide"));
            }
            else
            {
                ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists, see your system administrator.");
                return(View(lang));
            }
        }
コード例 #2
0
 public ActionResult AddGuide(Guide guide, Guidelang lang)
 {
     guide.Guideid    = Guid.NewGuid();
     guide.Uuid       = Guid.NewGuid();
     guide.Createdate = DateTime.Now;
     guide.Updatedate = DateTime.Now;
     guideService.Create(guide);
     guideService.SaveChanges();
     if (TryUpdateModel(lang, new string[] { "title", "contents" }) && ModelState.IsValid)
     {
         ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists, see your system administrator.");
         return(View(lang));
     }
     else
     {
         lang.Guideid = guide.Guideid;
         lang.Langid  = 1;
         HtmlDocument doc = new HtmlDocument();
         doc.LoadHtml(lang.Contents);
         guidelangService.Create(lang);
         guidelangService.SaveChanges();
         return(RedirectToAction("Guide"));
     }
 }