Beispiel #1
0
 //
 // GET: /search/
 public ActionResult searchPage(string keys)
 {
     if (keys == null || keys.Trim() == "") return RedirectToAction("Index", "HomePage");
     using (DatabaeEntities db = new DatabaeEntities())
     {
         keys = keys.Trim().ToLower();
         var data = (from a in db.ShowHomes
                     select new thumbHome
                     {
                         linkTitle = a.Title,
                         type = a.Type,
                         linkPage = a.linkPage,
                         summary = a.Summary
                     }).ToList();
         List<thumbHome> result = new List<thumbHome>(data.Count);
         foreach (var i in data)
         {
             var line = System.IO.File.ReadAllLines(Server.MapPath("~\\Views" + i.linkPage + ".cshtml"));
             int length = line.Length;
             for (int j = 0; j < length; j++ )
             {
                 if (line[j].ToLower().Contains(keys))
                 {
                     result.Add(i);
                     break;
                 }
             }
             //if (line)
         }
         return View(new resSearch(result, keys));
     }
 }
 //hihi
 //
 // GET: /HomePage/
 public ActionResult Index()
 {
     using (var db = new DatabaeEntities())
     {
         var data = (from a in db.ShowHomes
                     orderby a.dateWritten descending
                     select new thumbHome
                     {
                         linkTitle = a.Title,
                         summary = a.Summary,
                         linkIma = a.linkImage,
                         dateUpdate = a.dateWritten.ToString(),
                         linkPage = a.linkPage,
                         type = a.Type
                     }).Take(10).ToList();
         var t = data.First().linkIma;
         return View(data);
     }
 }
        public ActionResult Login_in(User_Table u)
        {
            if (u == null) return RedirectToAction("LoginFail", "Account");
            using (var db = new DatabaeEntities())
            {
                var data = (from a in db.User_Table
                            where u.password.Equals(a.password) && u.Email.Equals(a.Email)
                            select a).ToList();
               if (data == null){
                   ViewBag.Error = "Sai mật khẩu hoặc email";
                   return RedirectToAction("LoginFail", "Account");
               }
               else
               {
                   return RedirectToAction("Index", "HomePage");
               }

            }
        }
Beispiel #4
0
        public ActionResult submit(User_Table u)
        {
            using (DatabaeEntities db = new DatabaeEntities())
            {
                var data = (from a in db.User_Table
                            where u.password.Equals(a.password) && u.Email.Equals(a.Email)
                            select a).ToList();
               if (data.Count == 0){
                   return RedirectToAction("LoginF", "User");
               }
               else
               {

                   Session["kk"] = data.First().username;
                   Session["level"] = data.First().level;
                   return RedirectToAction("Index", "HomePage");
               }

            }
        }