public long InsertHistory(LoginHistory history) { using (var dba = new BetEXDataContainer()) { dba.AddToLoginHistories(history); dba.SaveChanges(); return history.ID; } }
public bool UpdateHistory(LoginHistory history) { using (var dba = new BetEXDataContainer()) { try { var Orghistory = dba.LoginHistories.Where(w => w.ID == history.ID).SingleOrDefault(); if (Orghistory != null) { Orghistory.LogoutTime = history.LogoutTime; dba.SaveChanges(); } return true; } catch { return false; } } }
public string LogOutAjax() { try { //update history //insert history login try { LoginHistory history = new LoginHistory(); history.ID = SessionManager.HISTORY_ID; history.LogoutTime = DateTime.Now; IoC.Resolve<ICustomerService>().UpdateHistory(history); } catch { } SessionManager.Logout(); return "success"; } catch { return null; } }
public ActionResult LogOn(LogOnModel model, string returnUrl) { if (ModelState.IsValid) { if (IoC.Resolve<ICustomerService>().Authenticate(model.UserName, FormsAuthentication.HashPasswordForStoringInConfigFile(model.Password.Trim(), "sha1"))) { FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe); //insert history login LoginHistory history = new LoginHistory(); history.MemberID = SessionManager.USER_ID; history.LoginTime = DateTime.Now; history.Status = Constant.Status.ACTIVENUM; history.IP = Request.UserHostAddress; IoC.Resolve<ICustomerService>().InsertHistory(history); if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/") && !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\")) { return Redirect(returnUrl); } else { return RedirectToAction("Index", "Home"); } } else { ModelState.AddModelError("", "The user name or password provided is incorrect."); } } // If we got this far, something failed, redisplay form return View(model); }
public string LoginAjax(string userName, string userPass) { if (IoC.Resolve<ICustomerService>().Authenticate(userName, FormsAuthentication.HashPasswordForStoringInConfigFile(userPass, "sha1"))) { FormsAuthentication.SetAuthCookie(userName, false); var member = IoC.Resolve<ICustomerService>().GetCustomerByUsername(userName); //insert history login LoginHistory history = new LoginHistory(); history.MemberID = member.MemberID; history.LoginTime = DateTime.Now; history.Status = Constant.Status.ACTIVENUM; history.IP = Request.UserHostAddress; IoC.Resolve<ICustomerService>().InsertHistory(history); var memberInfo = IoC.Resolve<ICustomerService>().GetCustomerByUsername(userName); return "success|" + memberInfo.FirstName + " " + memberInfo.LastName; } return null; }
/// <summary> /// Deprecated Method for adding a new object to the LoginHistories EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToLoginHistories(LoginHistory loginHistory) { base.AddObject("LoginHistories", loginHistory); }
/// <summary> /// Create a new LoginHistory object. /// </summary> /// <param name="id">Initial value of the ID property.</param> /// <param name="loginTime">Initial value of the LoginTime property.</param> /// <param name="status">Initial value of the Status property.</param> public static LoginHistory CreateLoginHistory(global::System.Int64 id, global::System.DateTime loginTime, global::System.Byte status) { LoginHistory loginHistory = new LoginHistory(); loginHistory.ID = id; loginHistory.LoginTime = loginTime; loginHistory.Status = status; return loginHistory; }