Esempio n. 1
0
        public ActionResult Login(string username, string password, int ulogaId = 2)
        {
            if (_db.FindByUsernamePassword(username, password) != null)
            {
                if (username == "admin" && password == "admin")
                {
                    Session["admin"] = username;
                    return(RedirectToAction("Index", "Advokats", new { area = "" }));
                }
                else if (_uDb.FindById(ulogaId) != null && ulogaId == 2)
                {
                    var obj = _db.GetKorisnici().FirstOrDefault(u => u.Username == username);
                    Session["UserID"] = obj.Id.ToString();

                    return(RedirectToAction("Index", "Advokats", new { area = "" }));
                }
            }

            TempData["ErrorMessage"] = "Uneti podaci nisu tačni! Pokušajte ponovo.";
            return(RedirectToAction("Index"));
        }