public ActionResult SaveSecUserInfo(SecUserInfo SecUsrInfo)
        {
            RBACUser rUser = new RBACUser(Session["UserName"].ToString());

            if (!rUser.HasPermission("SecUserInfo_Insert"))
            {
                return(Json("X", JsonRequestBehavior.AllowGet));
            }

            string eCode = "";

            using (var transaction = new TransactionScope())
            {
                try
                {
                    var UserInfo = _secUserInfoService.All().ToList().FirstOrDefault(x => x.UserName == SecUsrInfo.UserName);

                    if (UserInfo == null)
                    {
                        SecUserInfo SecUinf = new SecUserInfo();
                        SecUinf.UserName   = SecUsrInfo.UserName;
                        SecUinf.Password   = SHA1.Encode(SecUsrInfo.Password);
                        SecUinf.Email      = SecUsrInfo.Email;
                        SecUinf.CreateDate = System.DateTime.Now;
                        _secUserInfoService.Add(SecUinf);
                        _secUserInfoService.Save();
                        //For user branch table by Farhad
                        var        userId = _secUserInfoService.All().ToList().Where(x => x.UserName == SecUsrInfo.UserName).Select(s => s.UserID).FirstOrDefault();
                        UserBranch UB     = new UserBranch();
                        UB.Userid     = userId.ToString();
                        UB.BranchCode = "01";
                        _userBranchService.Add(UB);
                        _userBranchService.Save();
                        eCode = "1";
                    }
                    else
                    {
                        eCode = "2";
                    }

                    transaction.Complete();

                    return(Json(eCode, JsonRequestBehavior.AllowGet));
                }
                catch (Exception)
                {
                    transaction.Dispose();
                    return(Json("0", JsonRequestBehavior.AllowGet));
                }
            }
        }
        public ActionResult UserPasswordChange(LocalPasswordModel Lpm)
        {
            using (var transaction = new TransactionScope())
            {
                try
                {
                    string eCode = "";

                    if (Session["UserID"] != null)
                    {
                        int UserID = Convert.ToInt32(Session["UserID"].ToString());

                        var UserInfo = _secUserInfoService.All().ToList().FirstOrDefault(x => x.UserID == UserID);

                        if (UserInfo != null)
                        {
                            UserInfo.Password = SHA1.Encode(Lpm.NewPassword);

                            _secUserInfoService.Update(UserInfo);
                            _secUserInfoService.Save();

                            eCode = "1";
                        }
                        else
                        {
                            eCode = "2";
                        }
                    }
                    else
                    {
                        return(RedirectToAction("SecUserLogin", "SecUserLogin"));
                    }
                    @ViewBag.Message = eCode;

                    transaction.Complete();

                    return(View("~/Views/Security/ChangePassword.cshtml"));
                }
                catch (System.Exception)
                {
                    transaction.Dispose();
                    @ViewBag.Message = "0";
                    return(View("~/Views/Security/ChangePassword.cshtml"));
                }
            }
        }