Ejemplo n.º 1
0
        public ActionResult Login(string username, string password)
        {
            msadmin   msadmin   = this.msadmin.getAllData().SingleOrDefault <msadmin>(s => s.username == username && s.password == password);
            mspenyewa mspenyewa = this.mspenyewa.getAllData().SingleOrDefault <mspenyewa>(s => s.username == username && s.password == password);
            msrental  msrental  = this.msrental.getAllData().SingleOrDefault <msrental>(s => s.username == username && s.password == password);

            if (msadmin != null && msadmin.status == 1)
            {
                Session["admin"] = msadmin.id_admin;
                return(RedirectToAction("Index", "Admin"));
            }
            if (mspenyewa != null && mspenyewa.status == 1)
            {
                Session["error"]   = "Login berhasil!";
                Session["penyewa"] = mspenyewa.id_penyewa;
                return(RedirectToAction("Index", "Penyewa"));
            }
            if (msrental != null && msrental.status == 1)
            {
                Session["id"] = msrental.id_rental;
                return(RedirectToAction("Index", "Rental"));
            }
            Session["error"] = "Gagal untuk login, username atau password tidak tepat!";
            return(RedirectToAction("Index", "Penyewa"));
        }
Ejemplo n.º 2
0
        public JsonResult masuk(string username, string password)
        {
            msadmin   msadmin   = this.msadmin.getAllData().SingleOrDefault <msadmin>(s => s.username == username && s.password == password);
            mspenyewa mspenyewa = this.mspenyewa.getAllData().SingleOrDefault <mspenyewa>(s => s.username == username && s.password == password);
            msrental  msrental  = this.msrental.getAllData().SingleOrDefault <msrental>(s => s.username == username && s.password == password);

            if (msadmin != null && msadmin.status == 1)
            {
                Login(username, password);
            }
            if (mspenyewa != null && mspenyewa.status == 1)
            {
                Session["penyewa"]  = mspenyewa.id_penyewa;
                Session["username"] = username;
            }
            if (msrental != null && msrental.status == 1)
            {
                Login(username, password);
            }
            return(Json(mspenyewa.nama_penyewa, JsonRequestBehavior.AllowGet));
        }