Exemple #1
0
        public ActionResult Step2(CompanyBranchModel userCompany2)
        {
            int userId = (int)Session["userId"];
            //int userId = 68;

            BranchAccess ba = new BranchAccess();

            userCompany2.MainBranch.StateId    = userCompany2.StateId;
            userCompany2.MainBranch.BranchCode = ba.createBranchCode(userCompany.Company.CompanyCode);
            userCompany.MainBranch             = userCompany2.MainBranch;
            int reslt = ba.insertFirstBranchDetails(userCompany, userId);

            if (reslt > 0)
            {
                StepAccess sa = new StepAccess();
                if (sa.updateStepNumberByUserId(userId, 3))
                {
                    bool reslt2 = ba.updateUserBranchId(userCompany2, userId);
                    if (reslt2)
                    {
                        return(RedirectToAction("Step3"));
                    }
                }
            }
            else
            {
                ViewBag.ErrorMsg = "Failed to create first branch";
            }
            return(View());
        }
        public ActionResult CreateBranchPost(Branch branch)
        {
            ViewBag.Type = "";

            int id = userData.UserId;
            //branch.StateId = branch.StateId2;
            BranchAccess br = new BranchAccess();
            //int reslt = br.insertBranchDetails(branch, id);
            int           reslt     = 0;
            CompanyAccess ca        = new CompanyAccess();
            List <State>  stateList = ca.GetAllStates();

            ViewBag.StateId = new SelectList(stateList, "StateId", "StateName");

            if (reslt > 0)
            {
                ViewBag.SuccessMsg = "Branch is successfully added";
                return(RedirectToAction("CreateBranch", "CreateBranch", new { success = 1 }));
                //branch = new Branch();
                //return PartialView(branch);
            }
            else
            {
                ViewBag.ErrorMsg = "Failed to add branch";
                return(PartialView());
            }
        }
        public void SetBranches(IEnumerable <Branch> allBranches, ObjectId userID)
        {
            if (Branches is null)
            {
                Branches = new List <BranchDto>();
            }

            Branches = allBranches.Where(branch =>
            {
                BranchAccess access = branch.Accesses.FirstOrDefault(a => a.UserID == userID);
                return(access is {} && access.AccessType != BranchAccessType.NoAccess);
            }).Select(branch => new BranchDto(branch)).ToList();
Exemple #4
0
        public ActionResult LoanInfo(string title, string msg)
        {
            ViewBag.Msg = msg;
            int    userId;
            string loanCode = null;

            try {
                userId = userData.UserId;
            }
            catch (Exception)
            {
                return(RedirectToAction("UserLogin", "Login", new { lbl = "Due to inactivity your session has timed out, please log in again." }));
            }

            if (Session["loanCode"] != null)
            {
                loanCode = Session["loanCode"].ToString();
            }

            ViewBag.Title = title;

            ViewBag.Username = userData.UserName;
            BranchAccess ba = new BranchAccess();



            ViewBag.roleId = userData.RoleId;
            // get the Company type for front end view
            int comType = ba.getCompanyTypeByUserId(userId);

            ViewBag.loanCompanyType = (comType == 1) ? "Dealer" : "Lender";


            if (loanCode != null)
            {
                LoanSetupStep1 loan = (new LoanSetupAccess()).GetLoanDetailsByLoanCode(loanCode);
                Session["addUnitloan"] = loan;
                NonRegBranch nonRegBranch = ba.getNonRegBranchByNonRegBranchId(loan.nonRegisteredBranchId);

                ViewBag.NonRegBranchName = nonRegBranch.BranchName;

                //dealer email address, this will be used on curtailment page
                Session["DealerEmail"] = nonRegBranch.BranchEmail;

                ViewBag.loanBranchAddress = (nonRegBranch.BranchAddress1 != "" ? nonRegBranch.BranchAddress1 : "") + (nonRegBranch.BranchAddress2 != "" ? ", " + nonRegBranch.BranchAddress2 : "") + (nonRegBranch.BranchCity != "" ? ", " + nonRegBranch.BranchCity : "");

                ViewBag.CurtailmentDueDate = loan.CurtailmentDueDate;

                ViewBag.LoanNumber = loan.loanNumber;
            }

            return(View());
        }
 public ActionResult CreateBranchFirstBranch(UserCompanyModel userCompany)
 {
     if (_type == "CompanyEmployee")
     {
         ViewBag.Type = "CompanyEmployee";
         BranchAccess ba = new BranchAccess();
         userCompany.Branch.BranchCode = ba.createBranchCode(_userCompany.Company.CompanyCode);
         _userCompany.Branch           = userCompany.Branch;
         _userCompany.Branch.StateId   = userCompany.StateId;
         CompanyAccess ca = new CompanyAccess();
         //if (ca.SetupCompany(_userCompany))
         if (ca.SetupCompanyRollback(_userCompany))
         {
             ViewBag.SuccessMsg = "Company is successfully setup";
             return(View());
         }
         else
         {
             ViewBag.ErrorMsg = "Failed to setup company";
             return(RedirectToAction("CreateFirstSuperUser", "CreateUser"));
         }
     }
     return(View());
 }
Exemple #6
0
        /*
         * Frontend page: Update Titles
         * Title: Return View of Update Titles page
         * Designed: Piyumi
         * User story:
         * Developed: Piyumi
         * Date created: 03/17/2016
         */
        public ActionResult TitleStatusUpdate()
        {
            //Check Session["IsTitleTrack"] is not null and value is 0
            if (Session["IsTitleTrack"] != null && int.Parse(Session["IsTitleTrack"].ToString()) == 0)
            {
                //return to dashboard if title doesnot need to be tracked
                return(RedirectToAction("UserDetails", "UserManagement"));
            }
            //user role 3 - user
            else if (userData.RoleId == 3)
            {
                //Check Session["CurrentLoanRights"] is not null or empty
                if (Session["CurrentLoanRights"] == null || Session["CurrentLoanRights"].ToString() == "")
                {
                    //return to dashboard if Session["CurrentLoanRights"] is null or empty
                    return(RedirectToAction("UserDetails", "UserManagement"));
                }
                else
                {
                    var    checkPermission = false;
                    string rgts            = "";
                    //convert Session["CurrentLoanRights"] to string
                    rgts = (string)Session["CurrentLoanRights"];
                    string[] rgtList = null;
                    //Check string is not empty
                    if (rgts != "")
                    {
                        //split right string and insert to a list
                        rgtList = rgts.Split(',');
                    }
                    //Check list is not null
                    if (rgtList != null)
                    {
                        foreach (var x in rgtList)
                        {
                            //Check right list contains the relevant right which represent Update Titles page
                            if (x == "U02")
                            {
                                checkPermission = true;
                            }
                        }
                        //Check user is given permission to Update Titles page
                        if (checkPermission == false)
                        {
                            //if no permission to Update Titles page return to dashboard
                            return(RedirectToAction("UserDetails", "UserManagement"));
                        }
                    }
                    else
                    {
                        //if right list is null return to dashboard
                        return(RedirectToAction("UserDetails", "UserManagement"));
                    }
                }
            }
            //user role 4 - dealer user
            else if (userData.RoleId == 4)
            {
                //if dealer user return to dashboard
                return(RedirectToAction("UserDetails", "UserManagement"));
            }
            TitleStatus obj2 = new TitleStatus();

            obj2.TitleList = new List <Models.Unit>();
            int compType = 0;

            //get company type by company id
            if (userData.UserId > 0)
            {
                BranchAccess obj1 = new BranchAccess();
                compType = obj1.getCompanyTypeByUserId(userData.UserId);
            }
            //Check company type is greater than 0
            if (compType > 0)
            {
                //assign company type to viewbag variable
                ViewBag.CompanyType = compType;
            }
            int flag = -1;

            //Check result after updating title status
            if ((TempData["reslt"] != null) && (TempData["reslt"].ToString() != ""))
            {
                //assign result value to a variable
                flag = int.Parse(TempData["reslt"].ToString());
                //Check value of result
                if (flag == 1)
                {
                    ViewBag.Msg = "Success";
                }
                else if (flag == 0)
                {
                    ViewBag.Msg = "Error";
                }
                //return TitleStatus model object to view
                return(View(obj2));
            }
            else
            {
                //return TitleStatus model object to view
                return(View(obj2));
            }
        }
        /// <summary>
        /// Frontend page: Advance Unit
        /// Title: Get loan details and not advanced unit details from database and return to view
        /// Designed: Nadeeka
        /// User story:
        /// Developed: Nadeeka
        /// Date created: 02/24/2016
        /// </summary>
        /// <param name="model"></param>
        /// <returns>Return partial view</returns>
        public ActionResult Advance()
        {
            int flag = -1;
            //assign logged user id to variable
            int    userId = userData.UserId;
            string loanCode;

            try
            {
                //convert session to string variable
                loanCode = Session["loanCode"].ToString();
            }
            catch (Exception)
            {
                //if exception occured return to login page
                return(RedirectToAction("UserLogin", "Login"));
            }
            BranchAccess branch = new BranchAccess();
            //retrieve company type for given user id
            int companyType = branch.getCompanyTypeByUserId(userId);

            //check company type 1-Lender
            if (companyType == 1)
            {
                ViewBag.isLender = true;
            }
            //company type 2 - Dealer
            else
            {
                ViewBag.isLender = false;
            }

            ViewBag.unitClickId = "";
            LoanSetupStep1 loanDetails = new LoanSetupStep1();

            //retrieve loan delails for given loan code
            loanDetails = (new LoanSetupAccess()).GetLoanDetailsByLoanCode(loanCode);
            //check logged user role is user
            if (userData.RoleId == 3)
            {
                //check Session["CurrentLoanRights"] is null or empty
                if (Session["CurrentLoanRights"] == null || Session["CurrentLoanRights"].ToString() == "")
                {
                    return(RedirectToAction("UserDetails", "UserManagement"));
                }
                else
                {
                    var    checkPermission = false;
                    string rgts            = "";
                    //convert Session["CurrentLoanRights"] to string variable
                    rgts = (string)Session["CurrentLoanRights"];
                    string[] rgtList = null;
                    //check right string is not empty
                    if (rgts != "")
                    {
                        //split string
                        rgtList = rgts.Split(',');
                    }
                    //check right list is not null
                    if (rgtList != null)
                    {
                        foreach (var x in rgtList)
                        {
                            //check relevant right for Advance Unit page contains in the user right list
                            if (x == "U01")
                            {
                                checkPermission = true;
                            }
                        }
                        //check permission value is false
                        if (checkPermission == false)
                        {
                            //return to dashboard
                            return(RedirectToAction("UserDetails", "UserManagement"));
                        }
                    }
                    else
                    {
                        //return to dashboard
                        return(RedirectToAction("UserDetails", "UserManagement"));
                    }
                }
            }
            //check logged user is dealer user
            else if (userData.RoleId == 4)
            {
                //return to dashboard
                return(RedirectToAction("UserDetails", "UserManagement"));
            }
            ViewBag.loanDetails = loanDetails;
            Models.Unit unit = new Models.Unit();
            //get units which need to advance for given loan id
            AdvanceUnit advanceUnit = this.GetAdvanceUnitList(loanDetails.loanId);

            //assign loan id to session object
            Session["advUnitloanId"] = loanDetails.loanId;
            //assign not advanced unit list to session object
            Session["notAdvancedList"] = advanceUnit.NotAdvanced;
            ViewBag.advanceList        = advanceUnit.NotAdvanced;
            //check update result of Advance Unit page
            if ((TempData["updateReslt"] != null) && (TempData["updateReslt"].ToString() != ""))
            {
                //convert result to integer
                flag = int.Parse(TempData["updateReslt"].ToString());
            }
            //check result value is 1
            if (flag == 1)
            {
                //flag 1 - success
                ViewBag.Msg = "Success";
            }
            else if (flag == 0)
            {
                //flag 0 - error
                ViewBag.Msg = "Error";
            }
            else if (flag == 2)
            {
                //flag 2 - Advance amount error
                ViewBag.Msg = "Advance amount error";
            }
            else if (flag == 3)
            {
                //flag 3 - Advance error
                ViewBag.Msg = "Advance Error";
            }

            //return advance unit list to view
            return(View(advanceUnit));
        }
        /// <summary>
        /// Frontend page: Join Dealer
        /// Title: view of Link Dealer page
        /// Designed: Nadeeka
        /// User story:
        /// Developed: Nadeeka
        /// Date created: 2016/03/30
        /// Edited: Piyumi Perera
        /// </summary>
        /// <returns></returns>
        public ActionResult LinkDealer()
        {
            //Check result of Join Dealer page
            if (TempData["msg"] != null)
            {
                //Check TempData["msg"] is 1
                if (TempData["msg"].ToString() == "1")
                {
                    ViewBag.SuccessMsg = "User Successfully Created";
                }
                //Check TempData["msg"] is 2
                else if (TempData["msg"].ToString() == "2")
                {
                    ViewBag.Error = "Error";
                }
            }
            CompanyAccess ca   = new CompanyAccess();
            BranchAccess  ba   = new BranchAccess();
            Loan          loan = new Loan();

            //Check Session["oneLoanDashboard"] is not null
            if (Session["oneLoanDashboard"] != null)
            {
                //convert session object to loan object
                loan = (Loan)Session["oneLoanDashboard"];
            }
            //Check Session["loanDashboardJoinDealer"] is not null
            if (Session["loanDashboardJoinDealer"] != null)
            {
                //convert session object to loan object
                loan = (Loan)Session["loanDashboardJoinDealer"];
            }
            //remove Session["popUpSelectionType"]
            Session.Remove("popUpSelectionType");
            //return non registered branch details by non registered branch id
            NonRegBranch nonRegBranches = ba.getNonRegBranchByNonRegBranchId(loan.NonRegBranchId);

            ViewBag.nonRegBranches = nonRegBranches.BranchName;
            ViewBag.nonRegCompany  = nonRegBranches.CompanyNameBranchName;
            List <User> userList = new List <User>();

            //return all users of given company id
            userList = (new UserAccess()).GetUserListByCompany(userData.Company_Id);
            //filter user list who has authorization for selected loan
            userList = userList.FindAll(t => t.BranchId == loan.BranchId || (t.BranchId == 0 && t.RoleId == 1));
            ViewBag.UserIdForSendReq = new SelectList(userList, "UserId", "UserName");

            //get report list for dealer user
            List <Right> ReportRightsList = new List <Right>();
            User         us = new User();

            us.ReportRightsList = new List <Right>();
            ReportRightsList    = (new UserRightsAccess()).getReportRights();
            if (ReportRightsList != null && ReportRightsList.Count > 0)
            {
                foreach (Right rgt in ReportRightsList)
                {
                    //Check dealer user can view the report
                    if (!rgt.DealerView)
                    {
                        continue;
                    }
                    else
                    {
                        //check title need not to be tracked for selected loan and report right for Title Status
                        if ((loan.IsTitleTrack == 0) && (rgt.rightId == "R04"))
                        {
                            //if title need not to be tracked report right for Title Status is not added to right list
                            continue;
                        }
                        //check there is no advance fee for selected loan and report right for advance fee invoice and advance fee receipt
                        if ((loan.AdvanceFee == 0) && ((rgt.rightId == "R07") || (rgt.rightId == "R08")))
                        {
                            //if there is no advance fee, report right for advance fee invoice and advance fee receipt are not added to right list
                            continue;
                        }
                        //check there is no monthly loan fee for selected loan and report right for monthly loan fee invoice and monthly loan fee receipt
                        if ((loan.MonthlyLoanFee == 0) && ((rgt.rightId == "R09") || (rgt.rightId == "R10")))
                        {
                            //if there is no monthly loan fee, report right for monthly loan fee invoice and monthly loan fee receipt are not added to right list
                            continue;
                        }
                        //check there is no lot inspection fee for selected loan and report right for lot inspection fee invoice and lot inspection fee receipt
                        if ((loan.LotInspectionFee == 0) && ((rgt.rightId == "R11") || (rgt.rightId == "R12")))
                        {
                            //if there is no lot inspection fee, report right for lot inspection fee invoice and lot inspection fee receipt are not added to right list
                            continue;
                        }
                    }
                    us.ReportRightsList.Add(rgt);
                }
            }
            //Check user is super admin
            if (userData.RoleId == 1)
            {
                //convert user list to session object
                Session["UserReqList"] = userList;
            }
            //Check user is admin
            else if (userData.RoleId == 2)
            {
                //convert user list to session object
                Session["UserReqList"] = userList;
            }
            else
            {
                //return to dashboard
                return(RedirectToAction("UserDetails", "UserManagement"));
            }
            return(View(us));
        }
        public ActionResult LinkDealer(DealerUserModel user)
        {
            //initialize properties of user object
            user.PhoneNumber = user.PhoneNumber2;
            user.CreatedBy   = userData.UserId;
            user.IsDelete    = false;
            user.Status      = true;
            user.Company_Id  = userData.Company_Id;
            user.BranchId    = userData.BranchId;
            user.RoleId      = 4;
            user.Email       = user.NewEmail;

            BranchAccess ba   = new BranchAccess();
            Loan         loan = new Loan();

            //Check Session["oneLoanDashboard"] is not null
            if (Session["oneLoanDashboard"] != null)
            {
                //convert session object to loan object
                loan = (Loan)Session["oneLoanDashboard"];
            }
            //Check Session["loanDashboardJoinDealer"] is not null
            if (Session["loanDashboardJoinDealer"] != null)
            {
                //convert session object to loan object
                loan = (Loan)Session["loanDashboardJoinDealer"];
            }
            //initialize non registered branch id
            user.NonRegBranchId = loan.NonRegBranchId;
            //initialize loan id
            user.LoanId = loan.LoanId;
            //encrypt given password
            string passwordTemp = user.Password;

            UserAccess ua = new UserAccess();

            string newSalt = PasswordEncryption.RandomString();

            user.Password       = PasswordEncryption.encryptPassword(user.Password, newSalt);
            user.ActivationCode = Guid.NewGuid().ToString();
            //report rights
            string[] arrList = new string[user.ReportRightsList.Count];
            int      k       = 0;

            foreach (var y in user.ReportRightsList)
            {
                //Check whether a particular report right is given to user
                if (y.active)
                {
                    arrList[k] = y.rightId;
                    k++;
                }
            }
            arrList           = arrList.Where(x => !string.IsNullOrEmpty(x)).ToArray();
            user.ReportRights = string.Join(",", arrList);
            //Insert dealer user details and retrieve user id of inserted user
            int newUserId = ua.InsertDealerUser(user);

            //Check user id is not 0
            if (newUserId != 0)
            {
                //Generate email to send username and password to created dealer user
                string body = "Hi " + user.FirstName + "! <br /><br /> Your account has been successfully created. Below in your account detail." +
                              "<br /><br /> User name: " + user.UserName +
                              "<br /> Password : <b>" + passwordTemp +
                              "<br />Click <a href='www.dfpso.com'>here</a> to activate your account." +
                              "<br /><br/> Thanks,<br /> Admin.";

                Email email = new Email(user.Email);

                Session["abcRol"]  = user.RoleId;
                Session["abcBrnc"] = user.BranchId;
                email.SendMail(body, "Account details");
                //insert log record after user is created
                Log log = new Log(userData.UserId, userData.Company_Id, user.BranchId, user.LoanId, "Create Dealer Account", "Inserted Dealer : " + user.UserName, DateTime.Now);

                int islog = (new LogAccess()).InsertLog(log);

                TempData["msg"] = 1;
                return(RedirectToAction("LinkDealer"));
            }
            else
            {
                TempData["msg"] = 2;
                return(RedirectToAction("LinkDealer"));
            }
        }
        public ActionResult loadGrid()
        {
            string loanCode;

            try
            {
                loanCode = Session["loanCode"].ToString();
            }
            catch (Exception)
            {
                //filterContext.Controller.TempData.Add("UserLogin", "Login");
                return(RedirectToAction("UserLogin", "Login", new { lbl = "Due to inactivity your session has timed out, please log in again." }));
            }

            LoanSetupStep1 loanDetails = new LoanSetupStep1();

            loanDetails = (new LoanSetupAccess()).GetLoanDetailsByLoanCode(loanCode);



            BranchAccess ba = new BranchAccess();

            ViewBag.ComType     = userData.CompanyType;
            ViewBag.loanId      = loanDetails.loanId;
            ViewBag.loanDetails = loanDetails;

            UnitPayOffViewModel unitPayOffViewModel = new UnitPayOffViewModel();
            CurtailmentAccess   payoff = new CurtailmentAccess();

            unitPayOffViewModel.UnitPayOffList = new List <UnitPayOffModel>();
            unitPayOffViewModel.PayDate        = DateTime.Now;

            unitPayOffViewModel.UnitPayOffList = payoff.GetUnitPayOffList(loanDetails.loanId);

            decimal advanceFee = 0;

            advanceFee = payoff.AdvanceForPayOffUnits(loanDetails.loanId);

            //int advanceFeeAtPayoff = payoff.CheckAdvanceFeeAtPayOff(loanDetails.loanId);

            //if (advanceFeeAtPayoff == 1) {
            //    foreach (var unit in unitPayOffViewModel.UnitPayOffList) {
            //        unit.IsAdvancePaid = false;
            //    }
            //}
            ViewBag.AdvanceFee = advanceFee;

            var unitPayOffList = unitPayOffViewModel.UnitPayOffList;

            Session["payoffList"] = unitPayOffList;
            ViewBag.payOffList    = unitPayOffList;

            TitleAccess ta    = new TitleAccess();
            Title       title = ta.getTitleDetails(loanDetails.loanId);

            Session["PayOffUnitloanId"] = loanDetails.loanId;

            if (title != null)
            {
                bool isTitleTrack = title.IsTitleTrack;
                if (isTitleTrack)
                {
                    ViewBag.IsTitleTrack = "Yes";
                }
            }

            return(PartialView(unitPayOffViewModel));
        }
Exemple #11
0
        /*
         *
         * Frontend page   : Add Unit
         * Title           : Add or Advance Units
         * Designed        : Kasun Samarawickrama
         * User story      :
         * Developed       : Kasun Samarawickrama
         * Date created    : 02/24/2016
         *
         */
        public ActionResult AddUnit()
        {
            // Handle Record successfully update or Error message

            int Flag = 0;

            if (TempData["Msg"] != null)
            {
                Flag = int.Parse(TempData["Msg"].ToString());
                if (Flag == 1)
                {
                    ViewBag.Msg = "Success";
                }
                else if (Flag == 3)
                {
                    ViewBag.Msg = "Requested";
                }
                else if (Flag == 2)
                {
                    ViewBag.Msg = "Error";
                }
            }


            int userId = userData.UserId;

            ViewBag.Role = userData.RoleId;;

            //Check loan is null or not
            if (Session["loanCode"] == null || Session["loanCode"].ToString() == "")
            {
                return(RedirectToAction("UserLogin", "Login", new { lbl = "Failed find loan" }));
            }

            // for role id3 - user section
            if (userData.RoleId == 3)
            {
                // check user has rights to access this loan - if not redirect to dashboard
                if (Session["CurrentLoanRights"] == null || Session["CurrentLoanRights"].ToString() == "")
                {
                    return(RedirectToAction("UserDetails", "UserManagement"));
                }
                else
                {
                    var checkPermission = false;
                    var checkAdvance    = false;

                    // check user permission to the site
                    string rgts = "";
                    rgts = (string)Session["CurrentLoanRights"];
                    string[] rgtList = null;
                    //spit the permission string
                    if (rgts != "")
                    {
                        rgtList = rgts.Split(',');
                    }
                    if (rgtList != null)
                    {
                        foreach (var x in rgtList)
                        {
                            //check user have rights to add unit page
                            if (x == "U04")
                            {
                                checkPermission = true;
                            }
                            // check user have right to advance units in this page
                            if (x == "U01")
                            {
                                checkAdvance = true;
                            }
                        }
                        if (checkAdvance == true)
                        {
                            ViewBag.advanceAllow = true;
                        }
                        else
                        {
                            ViewBag.advanceAllow = false;
                        }
                        if (checkPermission == false)
                        {
                            return(RedirectToAction("UserDetails", "UserManagement"));
                        }
                    }
                    else
                    {
                        return(RedirectToAction("UserDetails", "UserManagement"));
                    }
                }
            }
            string loanCode = Session["loanCode"].ToString();
            // retrive loan details
            LoanSetupStep1 loan = (new LoanSetupAccess()).GetLoanDetailsByLoanCode(loanCode);

            int loanId = loan.loanId;

            Session["addUnitloan"] = loan;


            ViewBag.loanDetails = loan;
            //set default unit type for add unit page
            if (loan.selectedUnitTypes.Count == 1)
            {
                ViewBag.UnitTypeId = loan.selectedUnitTypes[0].unitTypeName;
            }

            Models.Unit unit = new Models.Unit();

            unit.AdvancePt   = loan.advancePercentage;
            unit.LoanId      = loanId;
            unit.LoanAmount  = loan.loanAmount;
            unit.AdvanceDate = DateTime.Now;
            unit.StartDate   = loan.startDate;
            unit.EndDate     = loan.maturityDate;

            //get company type
            //1 - Lender
            //2 - Dealer
            BranchAccess ba          = new BranchAccess();
            int          companyType = ba.getCompanyTypeByUserId(userId);

            ViewBag.CompabyType = companyType;
            ViewBag.RoleId      = userData.RoleId;

            //Check title
            TitleAccess ta    = new TitleAccess();
            Title       title = ta.getTitleDetails(loan.loanId);

            // check title track allow or not
            if (title != null)
            {
                bool isTitleTrack = title.IsTitleTrack;
                if (isTitleTrack)
                {
                    ViewBag.IsTitleTrack = "Yes";
                }

                string upload = title.TitleAcceptMethod;
                if (!string.IsNullOrEmpty(upload) && upload == "Scanned Title Adequate")
                {
                    ViewBag.Upload = "Yes";
                }
            }
            // loan Details for (loan Detail box) in the page
            UnitAccess         ua = new UnitAccess();
            LoanPaymentDetails loanPaymentDetails = ua.GetLoanPaymentDetailsByLoanId(loanId);

            unit.Balance = loanPaymentDetails.BalanceAmount;
            // check balane field is editable or not for this loan
            ViewBag.Editable = loan.isEditAllowable ? "Yes" : "No";


            //set user role to restrict add & advance unit if this user is dealer user(role id = 4)
            ViewBag.RoleId = userData.RoleId;

            return(PartialView(unit));
        }