示例#1
0
 public ActionResult Create(ArticleViewModel model)
 {
     if (ModelState.IsValid)
     {
         try
         {
             Article article = new Article()
             {
                 AddTime = DateTime.Now,
                 ArticleCode = model.ArticleCode,
                 Content = model.Content,
                 Name = model.Name,
                 LastTime = DateTime.Now
             };
             ArticleService.Create(article);
             return RedirectToAction("index");
         }
         catch (Exception ex)
         {
             ViewBag.Message = ex.Message;
             return View(model);
         }
     }
     else
     {
         return View(model);
     }
 }
示例#2
0
 public void Update(ArticleViewModel model)
 {
     Article article = Find(model.ID);
     DB_Service.Attach<Article>(article);
     article.ArticleCode = model.ArticleCode;
     article.Content = model.Content;
     article.Name = model.Name;
     article.LastTime = DateTime.Now;
     DB_Service.Commit();
 }
示例#3
0
 public ActionResult Edit(ArticleViewModel model)
 {
     if (ModelState.IsValid)
     {
         try
         {
             ArticleService.Update(model);
             return RedirectToAction("index");
         }
         catch (Exception ex)
         {
             ViewBag.Message = ex.Message;
             return View(model);
         }
     }
     else
     {
         return View(model);
     }
 }
示例#4
0
 public ActionResult Edit(int id)
 {
     Article article = ArticleService.Find(id);
     ArticleViewModel model = new ArticleViewModel()
     {
         Name = article.Name,
         ID = article.ID,
         ArticleCode = article.ArticleCode,
         Content = article.Content
     };
     return View(model);
 }