Exemple #1
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());
        }
Exemple #2
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));
        }
Exemple #4
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));
        }