/// <summary> /// Deprecated Method for adding a new object to the tbl_LoginAudit EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddTotbl_LoginAudit(tbl_LoginAudit tbl_LoginAudit) { base.AddObject("tbl_LoginAudit", tbl_LoginAudit); }
public ActionResult Login(LoginModel model, string returnUrl) { if (!this.IsCaptchaValid("Captcha is not valid")) { ModelState.AddModelError("CaptchError", "Captcha is not valid"); return View(model); } if (ModelState.IsValid && WebSecurity.Login(model.UserName, model.Password, persistCookie: model.RememberMe)) { tbl_LoginAudit entity = null; var result = from c in db.tbl_LoginAudit where c.UserName == model.UserName select c; if (result.Count() > 0) entity = result.Single(); if (entity == null) { entity = new tbl_LoginAudit { UserName = model.UserName, LoginTime = DateTime.Now, IP = Request.ServerVariables["REMOTE_ADDR"] }; db.tbl_LoginAudit.AddObject(entity); } else { Session["LastLoginTime"] = entity.LoginTime; Session["CurrentLoginTime"] = DateTime.Now; entity.LoginTime = DateTime.Now; entity.IP = Request.ServerVariables["REMOTE_ADDR"]; //entity.LogOutTime = null; // db.ObjectStateManager.ChangeObjectState(entity, EntityState.Modified); } //db.SaveChanges(); return RedirectToLocal(returnUrl); } // If we got this far, something failed, redisplay form ModelState.AddModelError("LoginError", "user name or password provided is incorrect."); return View(model); }
/// <summary> /// Create a new tbl_LoginAudit object. /// </summary> /// <param name="lAudit_Id">Initial value of the LAudit_Id property.</param> /// <param name="loginTime">Initial value of the LoginTime property.</param> /// <param name="userName">Initial value of the UserName property.</param> public static tbl_LoginAudit Createtbl_LoginAudit(global::System.Int32 lAudit_Id, global::System.DateTime loginTime, global::System.String userName) { tbl_LoginAudit tbl_LoginAudit = new tbl_LoginAudit(); tbl_LoginAudit.LAudit_Id = lAudit_Id; tbl_LoginAudit.LoginTime = loginTime; tbl_LoginAudit.UserName = userName; return tbl_LoginAudit; }