Esempio n. 1
0
        public ActionResult Register()
        {
            string uName  = Request.Form["last_name"];
            string uEmail = Request.Form["email"];
            string uPsw   = Request.Form["password"];

            var anyUser = model.findUserByEmail(uEmail);

            if (anyUser == null)//不存在重复的邮箱
            {
                if (uPsw.Contains(" "))
                {
                    ViewBag.info = "密码不能包含空格,请重新输入";
                    indexModel index = new indexModel();
                    index.topics   = db.Topics.ToList();
                    index.question = new List <List <Question> >();
                    for (int i = 0; i < index.topics.Count(); i++)
                    {
                        List <Question> a   = new List <Question>();
                        int             tid = index.topics[i].TID;
                        a = db.Questions.Where(d => d.QTopicType1 == tid).ToList();
                        index.question.Add(a);
                    }
                    return(View("index", index));
                }
                else
                {
                    User user = model.addUser(uName, uEmail, uPsw);
                    addCookie("id", user.UID.ToString());
                    //登陆成功,进入个人主页界面
                    return(RedirectToAction("index", "people"));
                }
            }
            else
            {
                ViewBag.info = "该邮箱已经被注册";
                indexModel index = new indexModel();
                index.topics   = db.Topics.ToList();
                index.question = new List <List <Question> >();
                for (int i = 0; i < index.topics.Count(); i++)
                {
                    List <Question> a   = new List <Question>();
                    int             tid = index.topics[i].TID;
                    a = db.Questions.Where(d => d.QTopicType1 == tid).ToList();
                    index.question.Add(a);
                }
                return(View("index", index));
            }
        }
Esempio n. 2
0
        public ActionResult Login()
        {
            string uPas      = Request.Form["password"];
            string uEmail    = Request.Form["email"];
            User   loginUser = model.findUserByEmail(uEmail);

            if (loginUser == null)
            {
                ViewBag.info = "用户名错误";
                indexModel index = new indexModel();
                index.topics   = db.Topics.ToList();
                index.question = new List <List <Question> >();
                for (int i = 0; i < index.topics.Count(); i++)
                {
                    List <Question> a   = new List <Question>();
                    int             tid = index.topics[i].TID;
                    a = db.Questions.Where(d => d.QTopicType1 == tid).ToList();
                    index.question.Add(a);
                }
                return(View("index", index));
            }
            else
            {
                if (loginUser.UPassword == uPas)//登陆成功进入
                {
                    addCookie("id", loginUser.UID.ToString());
                    return(RedirectToAction("index", "index"));
                }
                else
                {
                    ViewBag.info = "密码错误";
                    indexModel index = new indexModel();
                    index.topics   = db.Topics.ToList();
                    index.question = new List <List <Question> >();
                    for (int i = 0; i < index.topics.Count(); i++)
                    {
                        List <Question> a   = new List <Question>();
                        int             tid = index.topics[i].TID;
                        a = db.Questions.Where(d => d.QTopicType1 == tid).ToList();
                        index.question.Add(a);
                    }
                    return(View("index", index));
                }
            }
        }
Esempio n. 3
0
 public ActionResult Index()
 {
     //如果用户已经注册 直接跳转到首页
     if (getCookie("id") != -1)
     {
         int        id = getCookie("id");
         IndexModel m  = model.loadIndex(id);
         return(View("newIndex", m));
     }
     else
     {
         indexModel index = new indexModel();
         index.topics   = db.Topics.ToList();
         index.question = new List <List <Question> >();
         for (int i = 0; i < index.topics.Count(); i++)
         {
             List <Question> a   = new List <Question>();
             int             tid = index.topics[i].TID;
             a = db.Questions.Where(d => d.QTopicType1 == tid).ToList();
             index.question.Add(a);
         }
         return(View(index));
     }
 }
Esempio n. 4
0
 public ActionResult Index()
 {
     //如果用户已经注册 直接跳转到首页
     if (getCookie("id") != -1)
     {
         int id = getCookie("id");
         IndexModel m = model.loadIndex(id);
         return View("newIndex", m);
     }
     else
     {
         indexModel index = new indexModel();
         index.topics = db.Topics.ToList();
         index.question = new List<List<Question>>();
         for (int i = 0; i < index.topics.Count(); i++)
         {
             List<Question> a = new List<Question>();
             int tid = index.topics[i].TID;
             a = db.Questions.Where(d => d.QTopicType1 == tid).ToList();
             index.question.Add(a);
         }
         return View(index);
     }
 }
Esempio n. 5
0
 public ActionResult Login()
 {
     string uPas = Request.Form["password"];
     string uEmail = Request.Form["email"];
     User loginUser = model.findUserByEmail(uEmail);
     if (loginUser == null)
     {
         ViewBag.info= "用户名错误";
         indexModel index = new indexModel();
         index.topics = db.Topics.ToList();
         index.question = new List<List<Question>>();
         for (int i = 0; i < index.topics.Count(); i++)
         {
             List<Question> a = new List<Question>();
             int tid = index.topics[i].TID;
             a = db.Questions.Where(d => d.QTopicType1 == tid).ToList();
             index.question.Add(a);
         }
         return View("index", index);
     }
     else
     {
         if (loginUser.UPassword == uPas)//登陆成功进入
         {
             addCookie("id", loginUser.UID.ToString());
             return RedirectToAction("index","index");
         }
         else
         {
             ViewBag.info = "密码错误";
             indexModel index = new indexModel();
             index.topics = db.Topics.ToList();
             index.question = new List<List<Question>>();
             for (int i = 0; i < index.topics.Count(); i++)
             {
                 List<Question> a = new List<Question>();
                 int tid = index.topics[i].TID;
                 a = db.Questions.Where(d => d.QTopicType1 == tid).ToList();
                 index.question.Add(a);
             }
             return View("index", index);
         }
     }
 }
Esempio n. 6
0
        public ActionResult Register()
        {
            string uName = Request.Form["last_name"];
            string uEmail = Request.Form["email"];
            string uPsw = Request.Form["password"];

            var anyUser = model.findUserByEmail(uEmail);
            if (anyUser == null)//不存在重复的邮箱
            {
                if (uPsw.Contains(" "))
                {
                    ViewBag.info = "密码不能包含空格,请重新输入";
                    indexModel index = new indexModel();
                    index.topics = db.Topics.ToList();
                    index.question = new List<List<Question>>();
                    for (int i = 0; i < index.topics.Count(); i++)
                    {
                        List<Question> a = new List<Question>();
                        int tid = index.topics[i].TID;
                        a = db.Questions.Where(d => d.QTopicType1 == tid).ToList();
                        index.question.Add(a);
                    }
                    return View("index", index);
                }
                else
                {
                    User user = model.addUser(uName, uEmail, uPsw);
                    addCookie("id", user.UID.ToString());
                    //登陆成功,进入个人主页界面
                    return RedirectToAction("index", "people");
                }
            }
            else
            {
                ViewBag.info = "该邮箱已经被注册";
                indexModel index = new indexModel();
                index.topics = db.Topics.ToList();
                index.question = new List<List<Question>>();
                for (int i = 0; i < index.topics.Count(); i++)
                {
                    List<Question> a = new List<Question>();
                    int tid = index.topics[i].TID;
                    a = db.Questions.Where(d => d.QTopicType1 == tid).ToList();
                    index.question.Add(a);
                }
                return View("index", index);
            }
        }