Esempio n. 1
0
        public ActionResult Authorize(projekat.Models.loginModel userModel)
        {
            using (loginContext db = new loginContext())
            {
                var loginDetails = db.login.Where(x => x.username == userModel.username && x.password == userModel.password).FirstOrDefault();


                if (loginDetails == null)
                {
                    //userModel.LoginErrorMessage = "Pogresno korisnicko ime ili sifra";
                    return(View("Index", userModel));
                }
                else
                {
                    Session["userID"]   = loginDetails.id;
                    Session["UserName"] = loginDetails.username;

                    if (loginDetails.userType.Equals("korisnik"))
                    {
                        return(RedirectToAction("User", "Home"));
                    }
                    else if (loginDetails.userType.Equals("admin"))
                    {
                        return(RedirectToAction("Admin", "Home"));
                    }
                    else if (loginDetails.userType.Equals("profesor"))
                    {
                        return(RedirectToAction("User2", "Home"));
                    }
                }
            }
            return(View("Index"));
        }
Esempio n. 2
0
        public ActionResult AddUser(projekat.Models.loginModel userModel)
        {
            using (loginContext db = new loginContext())
            {
                db.login.Add(userModel);
                db.SaveChanges();
                //userModel.SuccessAddUser = "******";
            }

            return(View("SuccessAddUser", userModel));
        }