Esempio n. 1
0
        public ActionResult login(loginviewmodel user, string returnUrl)
        {
            if (ModelState.IsValid)
            {
                AccountManager.SigninResult result = AccountManager.Signin(user.username, user.Password);
                switch (result)
                {
                case AccountManager.SigninResult.OK:
                    return(RedirectToAction("index", "Home"));

                case AccountManager.SigninResult.WrongPassword:
                    ViewBag.msg = "Wrong password you have entered";
                    return(View());

                case AccountManager.SigninResult.WrongUsername:
                    ViewBag.msg = "This username does not exist in records";
                    return(View());
                }
                return(View(returnUrl));
            }
            else
            {
                return(View(returnUrl));
            }
        }
        public async Task <ActionResult> Login(loginviewmodel model, string returnUrl = "")
        {
            //   var res = await SignInAsync();

            var _login = await SignInAsync(model.username, model.password, true);

            if (_login)
            {
                if (returnUrl != "")
                {
                    return(Redirect(returnUrl));
                }
                else
                {
                    return(RedirectToAction("dashboard", "home"));
                }
            }
            else
            {
                ViewBag.returnUrl = returnUrl;
                ViewBag.login     = false;
                return(View(model));
            }

            //if (res == Microsoft.AspNet.Identity.Owin.SignInStatus.Success)
            //{
            //    if (returnUrl == "" )
            //    {
            //        return RedirectToAction("dashboard", "home");
            //    }
            //    else
            //    {
            //        return Redirect(returnUrl);
            //    }
            //}
            //else
            //{
            //    ViewBag.returnUrl = returnUrl;
            //    ViewBag.login = false;
            //    return View(model);

            //}
        }
Esempio n. 3
0
        public ActionResult login(loginviewmodel model)
        {
            if (ModelState.IsValid)
            {
                /*  var count = (from c in db.customers where c.customerid == model.loginid && c.customerpassword == model.password select c).Count();*/

                var count = db.customers.Count(c => c.customerid == model.loginid && c.customerpassword == model.password);
                if (count > 0)
                {
                    Session["loginid"] = model.loginid;
                    return(RedirectToAction("index", "home"));
                }
                else
                {
                    ViewBag.msg = "invalid id or password";
                    return(View());
                }
            }
            else
            {
                return(View());
            }
        }
Esempio n. 4
0
 public ActionResult login(loginviewmodel model)
 {
     if (ModelState.IsValid)
     {
         studentdal dal    = new studentdal();
         bool       status = dal.login(model);
         if (status == true)
         {
             Session["loginid"] = model.loginid;
             return(RedirectToAction("index", "student"));
         }
         else
         {
             ViewBag.msg = "invalid user id or password";
             ModelState.Clear();
             return(View());
         }
     }
     else
     {
         return(View());
     }
 }
Esempio n. 5
0
 public ActionResult Main_login(loginviewmodel model)
 {
     try
     {
         hospital_managementEntities db = new hospital_managementEntities();
         if (model.type == "patient")
         {
             foreach (Register_patient R in db.Register_patient)
             {
                 if (R.password == model.Password && R.email == model.Email)
                 {
                     return(RedirectToAction("MakeAppointment", "Patient"));
                 }
             }
         }
         else if (model.type == "Doctor")
         {
             foreach (Register_doctor R in db.Register_doctor)
             {
                 if (R.password == model.Password && R.email == model.Email && R.type == model.type && R.status == 1)
                 {
                     return(RedirectToAction("Addprescription", "Doctor"));
                 }
             }
         }
         else
         {
             return(View());
         }
     }
     catch (Exception e)
     {
         return(View());
     }
     return(View());
 }