Example #1
0
        public ActionResult InitAuthPages()
        {
            //   public void InitAuthorizePage(int elt_account_number, int user_id, int user_type)
            int user_id         = Convert.ToInt32(Request.QueryString["user_id"]);
            int user_type       = Convert.ToInt32(Request.QueryString["user_type"]);
            AuthenticationBL bl = new AuthenticationBL();
            string           elt_account_number = Request.Cookies["CurrentUserInfo"]["elt_account_number"];
            var  me     = bl.GetELTUser(User.Identity.Name);
            bool result = false;

            if (me.user_type == "9")
            {
                result = bl.InitAuthorizePage(int.Parse(elt_account_number), user_id, user_type);
            }
            return(new ContentResult()
            {
                Content = result.ToString()
            });
        }
Example #2
0
        public ActionResult CreateNewUser()
        {
            bool result = false;

            // if (ConfigurationManager.AppSettings["SysAdmin"] == "True")
            {
                int              user_id            = Convert.ToInt32(Request.QueryString["user_id"]);
                int              user_type          = Convert.ToInt32(Request.QueryString["user_type"]);
                string           word               = Request.QueryString["word"];
                AuthenticationBL bl                 = new AuthenticationBL();
                string           elt_account_number = Request.Cookies["CurrentUserInfo"]["elt_account_number"];
                var              me                 = bl.GetELTUser(User.Identity.Name);

                if (me.user_type == "9")
                {
                    var newuser = bl.GetELTUser(elt_account_number, user_id);
                    try
                    {
                        string UserName = newuser.login_name;
                        if (!WebSecurity.UserExists(UserName))
                        {
                            WebSecurity.CreateUserAndAccount(UserName, word, new { elt_account_number = elt_account_number });
                        }
                    }
                    catch (MembershipCreateUserException e)
                    {
                        ModelState.AddModelError("", ErrorCodeToString(e.StatusCode));
                    }
                    result = bl.InitAuthorizePage(int.Parse(elt_account_number), user_id, user_type);
                }
            }
            return(new ContentResult()
            {
                Content = result.ToString()
            });
        }
Example #3
0
        public ActionResult UpdateLogin()
        {
            string newlogin   = Request.QueryString["loginId"];
            string oldLoginId = Request.QueryString["oldLoginId"];
            string Content    = "True";

            if (oldLoginId == User.Identity.Name)
            {
                Content = "Self";
            }
            AuthenticationBL bl = new AuthenticationBL();
            string           elt_account_number = Request.Cookies["CurrentUserInfo"]["elt_account_number"];
            var    me     = bl.GetELTUser(User.Identity.Name);
            bool   result = false;
            string Msg    = "";

            if (me.user_type == "9")
            {
                result = bl.UpdateLoginId(newlogin, oldLoginId, Convert.ToInt32(elt_account_number), out Msg);

                if (result == true)
                {
                    return(new ContentResult()
                    {
                        Content = Content
                    });
                }
                else
                {
                    if (Msg == "UserNotCreated")
                    {
                        Msg = "";
                        var OLD = bl.GetELTUser(oldLoginId);
                        if (OLD.login_name == oldLoginId)
                        {
                            WebSecurity.CreateUserAndAccount(oldLoginId, OLD.password);
                            using (UsersContext db = new UsersContext())
                            {
                                UserProfile user = db.UserProfiles.FirstOrDefault(u => u.UserName.ToLower() == oldLoginId.ToLower());
                                if (user != null)
                                {
                                    user.elt_account_number = me.elt_account_number;
                                    db.SaveChanges();
                                }
                            }
                            result = bl.UpdateLoginId(newlogin, oldLoginId, Convert.ToInt32(elt_account_number), out Msg);
                            if (result)
                            {
                                result = bl.InitAuthorizePage(int.Parse(elt_account_number), int.Parse(OLD.userid), int.Parse(OLD.user_type));
                                if (!result)
                                {
                                    Msg = "Initial Authorization Failed!";
                                }
                            }
                        }
                        if (result == true)
                        {
                            return(new ContentResult()
                            {
                                Content = Content
                            });
                        }
                        else
                        {
                            return(new ContentResult()
                            {
                                Content = Msg
                            });
                        }
                    }
                    return(new ContentResult()
                    {
                        Content = Msg
                    });
                }
            }
            else
            {
                return(new ContentResult()
                {
                    Content = "You are not allowed to perform this action"
                });
            }
        }