예제 #1
0
파일: User.cs 프로젝트: shainberg/Library
        public static Boolean isUserAdmin(string id)
        {
            paradiseContext context = new paradiseContext();
            var answer = from users in context.users
                         where users.id == id &&
                               users.isAdmin == true
                         select true;

            return (answer.Count() == 1);
        }
예제 #2
0
        public ActionResult Login()
        {
            string id = this.Request["id"];
            string password = this.Request.Params["password"];

            if (id != null && password != null)
            {
                /*Query From users table*/
                paradiseContext context = new paradiseContext();
                var result = from users in context.users
                                where users.id.Equals(id) &&
                                users.password.Equals(password)
                                select users;

                if (result != null)
                {
                    User[] users = result.ToArray<User>();

                    if (users.Length == 1)
                    {
                        HttpContext.Session.Add("Connected", users[0].id);

                        if (true.Equals(users[0].isAdmin))
                        {
                            HttpContext.Session.Add("IsAdmin", true);
                        }

                        ViewBag.Error = false;
                        return RedirectToAction("index", "Home");
                    }
                }
            }

            ViewBag.Error = true;
            return View("LoginNew");
        }