Beispiel #1
0
        //Check whether username is existing
        public JsonResult IsUsernameExisting(string chkUserName)
        {
            FormsAuthenticationTicket ticket = null;

            try
            {
                _UserDetailsBusinessLogic = new UserDetailsBusinessLogic();

                bool isExisting = _UserDetailsBusinessLogic.IsUsernameExisting(chkUserName);

                return(Json(isExisting));
            }
            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));
            }
        }
Beispiel #2
0
        /****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));
            }
        }