示例#1
0
 public ActionResult Promote(int id)
 {
     try
     {
         if (int.Parse(Session["Id"].ToString()) != id)
         {
             ModeratorDAO dao  = new ModeratorDAO();
             UserDAO      udao = new UserDAO();
             if (dao.SearchByUserId(id) == null)
             {
                 Moderator m = new Moderator();
                 m.UserId = id;
                 dao.Add(m);
                 Moderator mod = dao.SearchByUserId(id);
                 User      u   = udao.SearchById(id);
                 u.ModeratorId = mod.Id;
                 udao.Update();
             }
         }
         return(RedirectToAction("Register"));
     }
     catch
     {
         return(RedirectToAction("Index", "Home"));
     }
 }