public ActionResult Index(LoginRequestModel model, string returnUrl = null) { try { if (Session["User"] != null) { return(RedirectToAction("Index", "Home", new { area = "" })); } if (ModelState.IsValid) { UserFactory factoy = new UserFactory(); CurrencyFactory _CurrencyFactory = new CurrencyFactory(); LoginResponseModel User = factoy.Login(model.Email, model.Password); bool isValid = (User != null && !string.IsNullOrEmpty(User.EmployeeID)); if (isValid) { UserSession userSession = new UserSession(); userSession.Email = User.EmployeeEmail; userSession.UserName = User.EmployeeName; userSession.UserId = User.EmployeeID; userSession.IsAuthenticated = true; userSession.ImageUrl = User.EmployeeImageURL; userSession.ListPermission = User.ListPermission; userSession.PinCode = User.EMployeePincode; //userSession.IsSuperAdmin = User.IsSuperAdmin; //userSession.OrganizationId = User.MerchantID; // userSession.OrganizationName = User.MerchantName; userSession.RoleID = User.RoleID; userSession.RoleName = User.RoleName; userSession.RoleLevel = User.RoleLevel; userSession.FTPPassword = User.FTPPassword; userSession.FTPUser = User.FTPUser; userSession.FTPWebImage = User.FTPWebImage; userSession.PublicImages = User.PublicImages; //get currency var obj = _CurrencyFactory.GetCurrencyCurrent(); if (obj != null) { userSession.CurrencySymbol = obj.Symbol; } Session.Add("User", userSession); //Tuấn edit if (!string.IsNullOrEmpty(mController)) { return(RedirectToAction("Index", mController, new { area = "" })); } if (returnUrl == null) { return(RedirectToAction("Index", "Home", new { area = "" })); } else { return(Redirect(returnUrl)); } } else { ModelState.AddModelError("", "Email/Password is incorrect!"); return(View(model)); } } else { return(View(model));// Return Error page } } catch (Exception ex) { NSLog.Logger.Error("Index : ", ex); return(new HttpStatusCodeResult(400, ex.Message)); } }