public JsonResult UpdateSystemUser(SystemUser systemUser) { FormsAuthenticationTicket ticket = null; try { bool isSuccess = false; _UserDetailsBusinessLogic = new UserDetailsBusinessLogic(); HttpCookie authCookie = System.Web.HttpContext.Current.Request.Cookies[FormsAuthentication.FormsCookieName]; ticket = FormsAuthentication.Decrypt(authCookie.Value); int currentUserId = redirectedUserId == 0? _UserDetailsBusinessLogic.GetUserID(ticket.Name): redirectedUserId; isSuccess = _UserDetailsBusinessLogic.UpdateSytemUser(systemUser, currentUserId); return(Json(isSuccess)); } catch (Exception ex) { currentFile = this.ControllerContext.RouteData.Values["controller"].ToString(); // System.Diagnostics.StackTrace(true).GetFrame(0).GetFileName(); StackTrace st = new StackTrace(); StackFrame sf = st.GetFrame(0); methodName = sf.GetMethod().Name; ErrorLogHelper.UpdatingErrorLog(currentFile + "-" + methodName, ticket == null ? "N/A" : ticket.Name, ex); return(Json(false)); } }
/****Adding New User****/ public JsonResult AddOrUpdateSystemUser(SystemUser systemUser) { FormsAuthenticationTicket ticket = null; try { _UserDetailsBusinessLogic = new UserDetailsBusinessLogic(); bool isSuccess; int currentUserId = 0; //Getting current user.. HttpCookie authCookie = System.Web.HttpContext.Current.Request.Cookies[FormsAuthentication.FormsCookieName]; if (authCookie != null) { ticket = FormsAuthentication.Decrypt(authCookie.Value); currentUserId = _UserDetailsBusinessLogic.GetUserID(ticket.Name); } if (_UserDetailsBusinessLogic.IsUsernameExisting(systemUser.Username) == true && currentUserId != 0) { isSuccess = _UserDetailsBusinessLogic.UpdateSytemUser(systemUser, currentUserId); } else { isSuccess = _UserDetailsBusinessLogic.AddSystemUser(systemUser, currentUserId); } return(Json(isSuccess)); } catch (Exception ex) { currentFile = this.ControllerContext.RouteData.Values["controller"].ToString(); // System.Diagnostics.StackTrace(true).GetFrame(0).GetFileName(); StackTrace st = new StackTrace(); StackFrame sf = st.GetFrame(0); methodName = sf.GetMethod().Name; ErrorLogHelper.UpdatingErrorLog(currentFile + "-" + methodName, ticket == null ? "N/A" : ticket.Name, ex); return(Json(false)); } }