public ActionResult UserDashBoard()
        {
            ViewBag.login = false;

            var id = userData.UserId;

            var dashBoardModel = new Models.DashBoard();

            var newDashDAL = new DashBoardAccess();

            if (id > 0)
            {
                ///get level id by userid
                int userLevelId = newDashDAL.GetUserLevelByUserId(id);

                dashBoardModel.userId   = id;
                dashBoardModel.userName = userData.UserName;
                dashBoardModel.roleName = (new UserManageAccess()).getUserRoleName(id);
                if (userLevelId == 1)
                {
                    dashBoardModel.levelId = 1;
                    return(PartialView("~/Views/Shared/_UserDetail.cshtml", dashBoardModel));
                }
                else if (userLevelId == 2)
                {
                    dashBoardModel.levelId = 2;
                    return(PartialView("~/Views/Shared/_UserDetail.cshtml", dashBoardModel));
                }
                else if (userLevelId == 3)
                {
                    dashBoardModel.levelId = 3;
                    return(PartialView("~/Views/Shared/_UserDetail.cshtml", dashBoardModel));
                }
                else
                {
                    return(RedirectToAction("UserLogin", "Login"));
                }
            }
            else
            {
                return(RedirectToAction("UserLogin", "Login"));
            }
        }
        /*
         *
         *  Frontend page: Report page
         *  Title: Get active loans of user for grid
         *  Designed: Kanishka SHM
         *  User story:
         *  Developed: Kanishka SHM
         *  Date created:
         *
         *  Edited By: Irfan MAM
         *  Purpose: Grid Functionality and user right access
         *
         */
        public ActionResult ReportIndex()
        {
            DashBoardAccess da        = new DashBoardAccess();
            int             loanCount = 0;


            ViewBag.RoleId   = _userData.RoleId;   //user role
            ViewBag.BranchId = _userData.BranchId; // branch

            // if user is a super admin
            if (_userData.RoleId == 1)
            {
                // get total number of active loans which belong to his company
                loanCount = da.GetLoanCount(_userData.Company_Id, _userData.RoleId);

                ViewBag.ComId = _userData.Company_Id;
                //branch list
                List <Branch> branchList = (new BranchAccess()).GetLoansBranches(_userData.Company_Id);

                var slectListBranches = new List <SelectListItem>();

                foreach (var br in branchList)
                {
                    slectListBranches.Add(new SelectListItem {
                        Text  = br.BranchName,
                        Value = br.BranchId.ToString()
                    });
                }
                ViewBag.BranchSelectList = slectListBranches;
                // if there is no active loan then redirect to login -- wrong access
                if (loanCount < 1)
                {
                    return(RedirectToAction("UserLogin", "Login"));
                }
            }
            // if user is a admin
            else if (_userData.RoleId == 2)
            {
                // get total number of active loans which belong to his branch
                loanCount          = da.GetLoanCount(_userData.BranchId, _userData.RoleId);
                ViewBag.BranchName = _userData.BranchName;
                // if there is no active loan then redirect to login -- wrong access
                if (loanCount < 1)
                {
                    return(RedirectToAction("UserLogin", "Login"));
                }
            }
            // if user is a user
            else if (_userData.RoleId == 3)
            {
                // get total number of autorized loans which belong to him
                loanCount = (new ReportAccess()).GetLoanCountAccountDetailsForUser(_userData.UserId);

                // if there is no authorized loan then redirect to login -- wrong access
                if (loanCount < 1)
                {
                    return(RedirectToAction("UserLogin", "Login"));
                }
                //  if user selected the authorized loan from dashboard
                else if (Session["CurrentLoanRights"] != null && Session["CurrentLoanRights"].ToString().Contains("U06"))
                {
                    // if loan count is equal to 1
                    if (loanCount == 1)
                    {
                        // get loan details of perticular loan
                        // pass it to view
                        ViewBag.loan = (new ReportAccess()).GetAccountDetailsForUser(_userData.UserId);
                    }
                }
                // if user selected the non authorized loan from dashboard
                else if (Session["CurrentLoanRights"] != null && !Session["CurrentLoanRights"].ToString().Contains("U06"))
                {
                    // clear the session of selected loan
                    Session["loanCode"]      = null;
                    Session["loanDashboard"] = null;


                    // if loan count is equal to 1
                    if (loanCount == 1)
                    {
                        // get that loan detail and report rights
                        List <Account> accounts = (new ReportAccess()).GetAccountDetailsForUser(_userData.UserId);

                        // if there is no other loan which has report rights -> redirect to login
                        if (accounts == null || accounts.Count < 1)
                        {
                            return(RedirectToAction("UserLogin", "Login"));
                        }
                        ViewBag.loan = accounts;
                        // set the session of selected loan
                        Session["loanCode"] = accounts[0].LoanCode;
                    }
                }
                // if user doesn't select the loan from the dashboard
                else
                {
                    if (loanCount == 1)
                    {
                        // get that loan detail and report rights
                        List <Account> accounts = (new ReportAccess()).GetAccountDetailsForUser(_userData.UserId);
                        ViewBag.loan = accounts;
                        // set the session of selected loan
                        Session["loanCode"] = accounts[0].LoanCode;
                    }
                }
            }
            // if user is a dealer
            else if (_userData.RoleId == 4)
            {
                loanCount = (new ReportAccess()).GetLoanCountAccountDetailsForUser(_userData.UserId);

                // dealer user can have only one account
                if (loanCount != 1)
                {
                    return(RedirectToAction("UserLogin", "Login"));
                }
                else
                {
                    // get that loan detail and report rights
                    List <Account> accounts = (new ReportAccess()).GetAccountDetailsForUser(_userData.UserId);
                    ViewBag.loan = accounts;
                }
            }
            ViewBag.getReportRights = (new UserRightsAccess()).getReportRights();
            ViewBag.loanCount       = loanCount;
            return(View());
        }