public ActionResult EditProfile(bq_User user) { bl_User bl_User = new bl_User(); bl_User.Update(user.UserId, user.UserName, user.Email, user.Gender, user.Birthday); return(View(user)); }
public ActionResult CloseWindows() { bl_User _objUser = new bl_User(); DateTime dCurrentLoginTime = DateTime.Now; string sCurrentLoginIP = string.Empty; // ********************************** // *************************************** string hostName = Dns.GetHostName(); // Retrive the Name of HOST sCurrentLoginIP = Dns.GetHostByName(hostName).AddressList[0].ToString(); // Get the #region Update Login Detail if (!string.IsNullOrWhiteSpace(_objAuthentication.UserName) && !string.IsNullOrWhiteSpace(_objAuthentication.Id)) { Guid guid = new Guid(_objAuthentication.Id); var vObj = _objUser.GetById(guid); if (vObj != null) { vObj.LastLoginTime = DateTime.Now; vObj.LastLoginIP = sCurrentLoginIP; _objUser.Update(vObj); } HttpCookie authCookie = HttpContext.Request.Cookies["UserInfo"]; if (authCookie != null) { authCookie.Values["LastLoginTime"] = Convert.ToString(DateTime.Now.ToString("dd/MM/yyyy") + ", " + DateTime.Now.ToString("hh:mm:ss tt")); authCookie.Values["LastLoginIP"] = sCurrentLoginIP; Response.SetCookie(authCookie); } } #endregion return(View()); }
public ActionResult Update(M_User objUser) { try { if (!string.IsNullOrWhiteSpace(Convert.ToString(objUser.Id))) { var vObj = _blUser.GetById(objUser.Id); if (vObj != null) { vObj.Phone = objUser.Phone; vObj.ModifyDate = DateTime.Now; vObj.ModifyBy = _objAuthentication.UserName; _blUser.Update(vObj); } } } catch (Exception ex) { throw ex; } return(Json(objUser)); }
public void UpdateAuthenticationDetail(M_User ObjUser) { bl_User _objUser = new bl_User(); DateTime dCurrentLoginTime = DateTime.Now; string sCurrentLoginIP = string.Empty; // ********************************** // *************************************** string hostName = Dns.GetHostName(); // Retrive the Name of HOST sCurrentLoginIP = Dns.GetHostByName(hostName).AddressList[0].ToString(); // Get the IP #region Authentication var vRoleName = _objLogin.GetUserRoleName(ObjUser); HttpCookie cookieUser = new HttpCookie("UserInfo"); cookieUser.Values.Add("Id", Convert.ToString(ObjUser.Id)); cookieUser.Values.Add("UserId", Convert.ToString(ObjUser.UserName)); cookieUser.Values.Add("Name", Convert.ToString(ObjUser.Name)); cookieUser.Values.Add("Email", Convert.ToString(ObjUser.Email)); cookieUser.Values.Add("Phone", Convert.ToString(ObjUser.Phone)); cookieUser.Values.Add("LastLoginTime", Convert.ToString(ObjUser.CurrentLoginTime.HasValue ? ObjUser.CurrentLoginTime.Value.ToString("dd/MM/yyyy") + ", " + ObjUser.CurrentLoginTime.Value.ToString("hh:mm:ss tt") : "[N/A]")); cookieUser.Values.Add("LastLoginIP", Convert.ToString(ObjUser.LastLoginIP)); cookieUser.Values.Add("CurrentLoginTime", Convert.ToString(dCurrentLoginTime != null ? dCurrentLoginTime.ToString("dd/MM/yyyy") + ", " + dCurrentLoginTime.ToString("hh:mm:ss tt") : "[N/A]")); cookieUser.Values.Add("CurrentLoginIP", Convert.ToString(sCurrentLoginIP)); cookieUser.Values.Add("RoleName", Convert.ToString(vRoleName)); cookieUser.Expires = DateTime.Now.AddDays(10.0); Response.Cookies.Add(cookieUser); // Success, create non-persistent authentication cookie. //FormsAuthentication.SetAuthCookie(vUserObject.UserName.Trim(), false); //FormsAuthenticationTicket ticket1 = // new FormsAuthenticationTicket( // 1, // version // vUserObject.UserName.Trim(), // get username from the form // DateTime.Now, // issue time is now // DateTime.Now.AddMinutes(10),// expires in 10 minutes // false, // cookie is not persistent // "HR" // role assignment is stored in userData // ); //HttpCookie cookieUser = new HttpCookie(FormsAuthentication.FormsCookieName, FormsAuthentication.Encrypt(ticket1)); //Response.Cookies.Add(cookieUser); #endregion #region Update Login Detail if (!string.IsNullOrWhiteSpace(Convert.ToString(ObjUser.Id))) { var vObj = _objUser.GetById(ObjUser.Id); if (vObj != null) { vObj.LastLoginTime = ObjUser.CurrentLoginTime; vObj.LastLoginIP = sCurrentLoginIP; vObj.CurrentLoginTime = dCurrentLoginTime; vObj.CurrentLoginIP = sCurrentLoginIP; _objUser.Update(vObj); } } #endregion }