Example #1
0
 [Authorize] // put authorize
 public ActionResult Index()
 {
     using (WebAppDemoEntities1 db = new WebAppDemoEntities1())
     {
         List <user> model = db.users.ToList();
         return(View(model));
     }
     return(View());
 }
        public ActionResult Index(user model)
        {
            using (WebAppDemoEntities1 db = new WebAppDemoEntities1())
            {
                //var userret = db.users.Where(x => x.username == model.username && x.password == model.password).FirstOrDefault();
                db.users.Add(model);
                db.SaveChanges();

                FormsAuthentication.SetAuthCookie(model.username, false);
                Session["username"] = model.username;
                return(Redirect("/home/index"));
            }
            return(View());
        }
Example #3
0
 private bool IsUsersValid(user m)
 {
     using (WebAppDemoEntities1 db = new WebAppDemoEntities1())
     {
         var userret = db.users.Where(x => x.username == m.username && x.password == m.password).FirstOrDefault();
         if (userret == null)
         {
             //m.response = "Wrong Username and Password";
             //return View("Index", m);
             return(false);
         }
         else
         {
             return(true);
         }
     }
     //return (m.username == "admin" && m.password == "admin");
 }