public ActionResult TryLogin()
        {
            SignUpViewModel signUpViewModel = new SignUpViewModel();
            signUpViewModel.SideBarData = new SideBarViewModel();
            signUpViewModel.SideBarData.CurrentIndex = 0;
            signUpViewModel.NavStatusData = new NavStatusViewModel();
            signUpViewModel.NavStatusData.LeftText = "Log in";
            signUpViewModel.NavStatusData.LeftLink = "/User/LogIn";
            signUpViewModel.NavStatusData.RightText = "Sign up";
            signUpViewModel.NavStatusData.RightLink = "/User/SignUp";

            UserInfoBusinessLayer userInfoBusinessLayer = new UserInfoBusinessLayer();
            List<UserInfo> userInfoList = userInfoBusinessLayer.GetUserInfoList();
            UserInfo userInfo = new UserInfo();
            userInfo.Mail = UniqueEmail(Request.Form["Mail"]);
            userInfo.Password = Request.Form["Password"];

            bool LoginFlag = false;

            foreach (UserInfo ui in userInfoList)
            {
                if (ui.Mail == userInfo.Mail && ui.Password == userInfo.Password)
                {
                    userInfo.NickName = ui.NickName;
                    LoginFlag = true;
                    break;
                }
            }

            if (LoginFlag == true)
            {
                signUpViewModel.NavStatusData.AlertType = "success";
                signUpViewModel.NavStatusData.Message = "Login successfully!";
                HttpContext.Session["Mail"] = userInfo.Mail;
                HttpContext.Session["User"] = userInfo.NickName;
                HttpContext.Session["Group"] = 1;

                Response.Redirect("~");
                return View("Index", signUpViewModel);
            }
            else
            {
                signUpViewModel.NavStatusData.Message = "Wrong Email or password";
                signUpViewModel.NavStatusData.AlertType = "danger";

                return View("Signup", signUpViewModel);
            }
        }
        public ActionResult TrySignUp()
        {
            SignUpViewModel signUpViewModel = new SignUpViewModel();
            UserInfoBusinessLayer userInfoBusinessLayer = new UserInfoBusinessLayer();
            List<UserInfo> userInfoList = userInfoBusinessLayer.GetUserInfoList();
            UserInfo userInfo = new UserInfo();
            userInfo.NickName = Request.Form["NickName"];
            userInfo.Mail = UniqueEmail(Request.Form["Mail"]);
            userInfo.Password = Request.Form["Password"];
            userInfo.Grade = 1;

            bool SignUpFlag = true;

            foreach (UserInfo ui in userInfoList)
            {
                if (ui.Mail == userInfo.Mail)
                {
                    SignUpFlag = false;
                    break;
                }
            }

            signUpViewModel.NickName = userInfo.NickName;
            signUpViewModel.Password = userInfo.Password;
            signUpViewModel.Mail = signUpViewModel.Mail;

            signUpViewModel.SideBarData = new SideBarViewModel();
            signUpViewModel.SideBarData.CurrentIndex = 0;

            if (SignUpFlag == true)
            {
                userInfoBusinessLayer.SignUp(userInfo);
                signUpViewModel.Message = "Signup successfully!";
                signUpViewModel.AlertType = "success";
                HttpContext.Session["User"]= userInfo.NickName;
                HttpContext.Session["Mail"] = userInfo.Mail;
                HttpContext.Session["Group"] = 1;

                return View("SignUp", signUpViewModel);
            }
            else
            {
                signUpViewModel.Message = "Email is invalid or already taken";
                signUpViewModel.AlertType = "danger";

                return View("SignUp", signUpViewModel);
            }
        }
        /* Create by Zhang Cong */
        public ActionResult UserInfoUpdate()
        {
            UserInfoBusinessLayer userInfoBusinessLayer = new UserInfoBusinessLayer();
            List<UserInfo> userInfoList = userInfoBusinessLayer.GetUserInfoList();
            UserInfo userInfo = new UserInfo();

            userInfo.Password = Request.Form["Password"];
            userInfo.Mail = HttpContext.Session["Mail"].ToString();
            foreach (UserInfo ui in userInfoList)
            {
                if (ui.Mail == userInfo.Mail)
                {
                    userInfo.Grade = ui.Grade;
                    userInfo.NickName = ui.NickName;
                    userInfoBusinessLayer.Del(ui);
                    break;
                }
            }
            userInfoBusinessLayer.Add(userInfo);
            Response.Redirect("~");
            return View("Profile");
        }
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            Database.SetInitializer(new DropCreateDatabaseIfModelChanges<OTSDBDAL>());

            /* Create by Dwayne 2015-12-4 14:05:12 */
            UserInfoBusinessLayer userInfoBusinessLayer = new UserInfoBusinessLayer();
            UserInfo userInfo = new UserInfo();
            userInfo.NickName = "Admin";
            userInfo.Mail = "*****@*****.**";
            userInfo.Password = "******";
            userInfo.Grade = 1;
            userInfoBusinessLayer.SignUp(userInfo);

            ArticleBusinessLayer articleBusinessLayer = new ArticleBusinessLayer();
            Article article = new Article();
            Regex rgx = new Regex("<[^>]+>");
            String TEMP;
            Markdown m = new Markdown();

                StreamReader SR1 = new StreamReader(Server.MapPath("./testArticle/Markdown_Documentation_Basics.text"));
                StreamReader SR2 = new StreamReader(Server.MapPath("./testArticle/Markdown_Documentation_Syntax.text"));
                StreamReader SR3 = new StreamReader(Server.MapPath("./testArticle/markdown-readme.text"));

                article.Author = "TestTest";
                article.CreateDate = DateTime.Now;
                article.Title = "Test" + (1).ToString();

                TEMP = SR1.ReadToEnd();
                article.Content = m.Transform(TEMP);
                TEMP = rgx.Replace(article.Content, " ");
                TEMP = TEMP.Replace("\n", "");
                if (TEMP.Length >= 80) article.Description = TEMP.Substring(0, 79) + "...";
                else article.Description = TEMP.Substring(0) + "...";

                articleBusinessLayer.UploadArticle(article);

                article.Author = "TestTest";
                article.CreateDate = DateTime.Now;
                article.Title = "Test" + (2).ToString();

                TEMP = SR2.ReadToEnd();
                article.Content = m.Transform(TEMP);
                TEMP = rgx.Replace(article.Content, " ");
                TEMP = TEMP.Replace("\n", "");
                if (TEMP.Length >= 80) article.Description = TEMP.Substring(0, 79) + "...";
                else article.Description = TEMP.Substring(0) + "...";

                articleBusinessLayer.UploadArticle(article);

                article.Author = "TestTest";
                article.CreateDate = DateTime.Now;
                article.Title = "Test" + (3).ToString();

                TEMP = SR3.ReadToEnd();
                article.Content = m.Transform(TEMP);
                TEMP = rgx.Replace(article.Content, " ");
                TEMP = TEMP.Replace("\n", "");
                if (TEMP.Length >= 80) article.Description = TEMP.Substring(0, 79) + "...";
                else article.Description = TEMP.Substring(0) + "...";

                articleBusinessLayer.UploadArticle(article);

                SR1.Close();
                SR2.Close();
                SR3.Close();
        }