Ejemplo n.º 1
0
 public ActionResult Add(UserRecommend model)
 {
     if (ModelState.IsValid)
     {
         try
         {
             UserRecommend recommend = new UserRecommend();
             recommend.UserID = model.UserID;
             db.UserRecommends.Add(recommend);
             db.SaveChanges();
             return Redirect("/Admin/Recommend/Index");
         }
         catch(Exception ex)
         {
             log.Error(new LogContent("增加推荐出错", HttpHelper.GetIPAddress()), ex);
         }
     }
     else
     {
         ModelState.AddModelError("", "推荐信息填写错误!");
     }
     return View();
 }
Ejemplo n.º 2
0
 public ActionResult Edit(int id)
 {
     UserRecommend recommend = new UserRecommend();
     recommend = db.UserRecommends.Find(id);
     ViewBag.Recommend = recommend;
     return View();
 }
Ejemplo n.º 3
0
 public ActionResult Edit(UserRecommend model)
 {
     if (ModelState.IsValid)
     {
         UserRecommend recommend = db.UserRecommends.Find(model.ID);
         recommend.UserID = model.UserID;
         recommend.Priority = model.Priority;
         db.SaveChanges();
         return Redirect("/Admin/Recommend/Index");
     }
     else
     {
         ModelState.AddModelError("", "推荐信息填写错误!");
     }
     return View();
 }