Esempio n. 1
0
        public ActionResult Login(UserVM uvm)
        {
            if (ModelState.IsValid)
            {
                string          IPAddress     = GetIPAddress();
                LoginRepository repository    = new LoginRepository();
                DataOperations  dataOperation = new DataOperations();
                string          result        = repository.DoLogin(uvm.UserName, EncodeAndDecode.Base64Encode(uvm.Password), IPAddress);

                if (result == "Uğurlu")
                {
                    tbl_User     userObj     = dataOperation.GetUserByUserName(uvm.UserName);
                    tbl_Employee employeeObj = dataOperation.GetEmployeeById(userObj.EmployeeID == null ? 0 : (Int64)userObj.EmployeeID);
                    UserProfile = new UserProfileSessionData()
                    {
                        UserId     = userObj.ID,
                        EmployeeID = employeeObj.ID,
                        UserName   = userObj.UserName,
                        FirstName  = employeeObj.FirstName,
                        LastName   = employeeObj.LastName,
                    };

                    this.Session["UserProfile"] = UserProfile;
                    UrlSessionData CurrentUrl = new UrlSessionData
                    {
                        Controller = "Home",
                        Action     = "Index"
                    };
                    this.Session["CurrentUrl"] = CurrentUrl;
                    return(RedirectToAction("Index", "Home"));
                }
                else if (result == "İstifadəçi adı tapılmadı")

                {
                    ViewBag.NotValidUser = result;
                }
                else
                {
                    ViewBag.Failedcount = result;
                }
                return(View("Index"));
            }
            else
            {
                return(View("Index", uvm));
            }
        }