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