コード例 #1
0
        public ActionResult DashBoard()
        {

            int userId = userData.UserId;

            var access = new UserRightsAccess();

            ///retrive all rights
            List<Right> rights = access.getRights();

            int userRole = userData.RoleId;

            if (userRole == 3)
            {
                ///get permission string for the relevent user
                List<Right> permissionString = access.getRightsString(userId, 0);
                if (permissionString.Count == 1)
                {


                    string permission = permissionString[0].rightsPermissionString;
                    if (permission != "")
                    {
                        string[] charactors = permission.Split(',');

                        List<Right> temprights = new List<Right>();

                        foreach (var charactor in charactors)
                        {
                            foreach (var obj in rights)
                            {
                                if (string.Compare(obj.rightId, charactor) == 0)
                                {
                                    temprights.Add(obj);
                                    break;

                                }

                            }
                        }

                        rights = temprights;


                    }
                    else
                    {
                        rights = new List<Right>();
                    }


                }

                else if (permissionString.Count == 0)
                {

                    rights = new List<Right>();
                }



            }

            return PartialView(rights);

        }
コード例 #2
0
        public List<Right> PermissionList(int userId, int loanId)
        {
            var access = new UserRightsAccess();

            //retrive all rights
            List<Right> rights = access.getRights();
            int userRole = (new UserManageAccess()).getUserRole(userId);

            if (userRole == 3)
            {
                //get permission string for the relevent user
                List<Right> permissionString = access.getRightsString(userId, loanId);
                if (permissionString.Count >= 1)
                {
                    string permission = permissionString[0].rightsPermissionString;
                    if (permission != "")
                    {
                        string[] charactors = permission.Split(',');

                        List<Right> temprights = new List<Right>();

                        foreach (var charactor in charactors)
                        {
                            foreach (var obj in rights)
                            {
                                if (String.CompareOrdinal(obj.rightId, charactor) == 0)
                                {
                                    temprights.Add(obj);
                                    break;
                                }
                            }
                        }
                        rights = temprights;
                    }
                    else
                    {
                        rights = new List<Right>();
                    }
                }
                else if (permissionString.Count == 0)
                {
                    rights = new List<Right>();
                }
            }

            return rights;
        }
コード例 #3
0
        /// <summary>
        /// CreatedBy : Kasun Samarawickrama
        /// CreatedDate: 2016/01/16
        /// Updated by   : kasun Samarawickrama
        /// Updated Date : 2016/01/18
        /// 
        /// Edit User Rights
        /// </summary>
        /// <param name="userId">login user </param>
        /// <param name="editorId">edit field user</param>
        /// <returns></returns>
        public ActionResult EditRights(string lbl1, string lbl2)

        {
            ViewBag.login = false;
            if (lbl1 != null)
            {
                ViewBag.SuccessMsg = lbl1;
            }
            else if (lbl2 != null)
            {
                ViewBag.ErrorMsg = lbl2;
            }
            else
            {
                ViewBag.SuccessMsg = "";
                ViewBag.ErrorMsg = "";
            }
            if (Session["userId"] == null)
            {
                return RedirectToAction("UserLogin", "Login");
            }
            if (Session["editUserIds"] == null)
            {
                return RedirectToAction("editUser", "UserManagement");
            }
            int userId = (int)Session["userId"];
            int ownerId = (int)Session["editUserIds"];

            if (userId > 0)
            {
                var access = new UserRightsAccess();

                ///retrive all rights
                List<Right> rights = access.getRights();

                ///get permission string for the relevent user
                List<Right> permissionString = access.getRightsString(ownerId,0);

                if (permissionString.Count == 1)
                {


                    string permission = permissionString[0].rightsPermissionString;
                    if (permission != "")
                    {
                        string[] charactors = permission.Split(',');

                        List<string> intArray = new List<string>();

                        foreach (var charactor in charactors)
                        {
                            intArray.Add(charactor);
                        }
                        foreach (var obj in rights)
                        {
                            obj.active = true;
                        }
                        foreach (var chr in intArray)
                        {
                            foreach (var obj in rights)
                            {
                                if (string.Compare(obj.rightId, chr) == 0)
                                {
                                    obj.active = false;
                                }
                                obj.editorId = userId;
                                obj.userId = ownerId;

                            }
                        }
                    }
                    else
                    {
                        foreach (var obj in rights)
                        {

                            obj.editorId = userId;
                            obj.userId = ownerId;

                        }

                    }

                }

                else if (permissionString.Count == 0)
                {
                    foreach (var obj in rights)
                    {

                        obj.editorId = userId;
                        obj.userId = ownerId;

                    }

                }
                else
                {
                    return RedirectToAction("editUser", "UserManagement");
                }
                ViewBag.userId = userId;
                ViewBag.ownerId = ownerId;

                return PartialView(rights);
            }
            else
            {
                return RedirectToAction("editUser", "UserManagement");
            }
        }
コード例 #4
0
        public ActionResult SetRights(IList<Right> rightList)
        {

            List<string> returnIntArray = new List<string>();

            for (int i = 0; i < rightList.Count;)
            {
                if (rightList[i].active == false)
                {
                    returnIntArray.Add(rightList[i].rightId);
                }
                i++;
            }
            var resultRightIdString = string.Join(",", returnIntArray);

            var returnRight = new Right();

            returnRight.userId = rightList[0].userId;
            returnRight.editorId = rightList[0].editorId;



            UserManageAccess uma = new UserManageAccess();
            // not allow to edit rights for admin and superadmin... not allow user to use this page
            if (uma.getUserRole(returnRight.userId) < 3 || uma.getUserRole(returnRight.editorId) == 3)
            {
                return new HttpStatusCodeResult(404);
            }
            returnRight.rightsPermissionString = resultRightIdString;

            var returnAccess = new UserRightsAccess();

            if (returnAccess.postNewRights(returnRight))
            {
                ViewBag.SuccessMsg = "Succesfully Updated";
                return RedirectToAction("SetRights", "EditRights", new { lbl1 = ViewBag.SuccessMsg });
            }
            else
            {
                ViewBag.ErrorMsg = "Sorry, rights can't update";
                return RedirectToAction("SetRights", "EditRights", new { lbl2 = ViewBag.ErrorMsg });
            }
        }
コード例 #5
0
        /// <summary>
        /// Frontend Page:Bottom Link Bar of each page in floor plan management section
        /// Title: return view according to user rights and loan setup details
        /// Designed: Irfan MAM
        /// User Story:
        /// Developed: Piyumi Perera
        /// Date created:
        /// </summary>
        /// <returns></returns>
        public ActionResult GetLinkBar()
        {
        //assign logged user id to int variable
            int userId = userData.UserId;
            string loanCode = "";

            UserRightsAccess access = new UserRightsAccess();

            //retrive all rights
            List<Right> rights = new List<Right>();
            //assign logged user role to int variable
            int userRole = userData.RoleId;
            //check Session["loanCode"] is not null and not empty
            if ((Session["loanCode"] != null) && (!string.IsNullOrEmpty(Session["loanCode"].ToString())))
            {
            //convert session to string variable
                loanCode = Session["loanCode"].ToString();
            }
            //check user role is user
            if (userRole == 3)
            {
            //retrieve rigts given for the loan 
                rights = access.GetUserRightsByLoanCode(loanCode, userId);
            }
            //assign user role to viewbag variable
            ViewBag.Role = userRole;

            //check Session["addUnitloan"] is null
            if (Session["addUnitloan"] == null)
            {
            //return to login page
                return RedirectToAction("UserLogin", "Login", new { lbl = "Failed find loan" });
            }
            //convert session to loan object
            LoanSetupStep1 loan = (LoanSetupStep1)Session["addUnitloan"];
            //check  Session["IsTitleTrack"] is not null
            if (Session["IsTitleTrack"] != null)
            {
            //check session value
                if (int.Parse(Session["IsTitleTrack"].ToString())==1)
                    {
                    //if 1 - title need to be tracked
                        ViewBag.ttlAccess = 1;
                    }
                    else
                    {
                    //else title no need to be tracked
                        ViewBag.ttlAccess = 0;

                    }
                
                
            }
            else
            {
                //else title no need to be tracked
                ViewBag.ttlAccess = 0;

            }
            //check Session["oneLoanDashboard"] which contains loan data if logged user has one loan is not null and not empty
            if ((Session["oneLoanDashboard"] != null) && (!string.IsNullOrEmpty(Session["oneLoanDashboard"].ToString())))
            {
                Loan loanObj = new Loan();
                //convert session to loan object
                    loanObj = (Loan)Session["oneLoanDashboard"];
                    //check if loan has at least one fee
                if ((loanObj.LotInspectionFee == 1) || (loanObj.MonthlyLoanFee == 1) || (loanObj.AdvanceFee == 1))
                    {
                    //assign value 1 for ViewBag.FeeLB
                    ViewBag.FeeLB = 1;
                    }
                    else
                    {
                    //assign value 0 for ViewBag.FeeLB
                    ViewBag.FeeLB = 0;
                    }
            }
            //check Session["loanDashboard"] which contains loan data if logged user select in popup is not null and not empty
            else if ((Session["loanDashboard"] != null) && (!string.IsNullOrEmpty(Session["loanDashboard"].ToString())))
            {
                Loan loanObj = new Loan();
                //convert session to loan object
                loanObj = (Loan)Session["loanDashboard"];
                //check if loan has at least one fee
                if ((loanObj.LotInspectionFee == 1) || (loanObj.MonthlyLoanFee == 1) || (loanObj.AdvanceFee == 1))
                {
                    //assign value 1 for ViewBag.FeeLB
                    ViewBag.FeeLB = 1;
                }
                else
                {
                    //assign value 0 for ViewBag.FeeLB
                    ViewBag.FeeLB = 0;
                }
            }
            //check Session["loanDashboard"] and check Session["oneLoanDashboard"] is null
            else if ((Session["oneLoanDashboard"] == null) && (Session["loanDashboard"] == null))
            {
            //return to login page
                return RedirectToAction("UserLogin", "Login");
            }
            //return right list to partial view
            return PartialView(rights);

        }