public int PayFees(List<Fees> lstFee, string type)
        {
            int userId = userData.UserId;  // set the user id
            FeeAccess feeAccess = new FeeAccess();
            LoanSetupStep1 loanDetails = new LoanSetupStep1();
            loanDetails = (new LoanSetupAccess()).GetLoanDetailsByLoanCode(Session["loanCode"].ToString()); // take the loan details by loan code
            int returnValue = feeAccess.updateFees(lstFee, lstFee[0].PaidDate, loanDetails.loanId, userId); // update fee details

            //if successfully updated, insert to log 
            if (returnValue == 1)
            {
                Log log;

                // if fee type is advance -- save details to log as advance fee
                if (type == "advanceFee")
                {
                    List<string> IDNumbers = new List<string>();
                    foreach (var fee in lstFee)
                    {
                        IDNumbers.Add(fee.IdentificationNumber);
                    }
                    log = new Log(userData.UserId, userData.Company_Id, userData.BranchId, loanDetails.loanId, "Pay Fees", "Advance Fee Paid for the unit(s) : " + string.Join(",", IDNumbers) + " , Pay Date : " + lstFee[0].PaidDate.ToString("dd/MM/yyyy"), DateTime.Now);
                    (new LogAccess()).InsertLog(log);

                }

                // if fee type is monthly loan -- save details to log as monthly loan fee
                else if (type == "monthlyLoanFee")
                {
                    List<string> DueDates = new List<string>();
                    foreach (var fee in lstFee)
                    {
                        DueDates.Add(fee.DueDate);
                    }

                    log = new Log(userData.UserId, userData.Company_Id, userData.BranchId, loanDetails.loanId, "Pay Fees", " Monthly Loan Fee Paid for the due date(s) : { " + string.Join(",", DueDates) + "}" + ", Pay Date : " + lstFee[0].PaidDate.ToString("dd/MM/yyyy"), DateTime.Now);
                    (new LogAccess()).InsertLog(log);
                }

                // if fee type is lot inspection fee -- save details to log as lot inspection fee
                else if (type == "lotInspectionFee")
                {
                    List<string> DueDates = new List<string>();

                    foreach (var fee in lstFee)
                    {
                        DueDates.Add(fee.DueDate);
                    }

                    log = new Log(userData.UserId, userData.Company_Id, userData.BranchId, loanDetails.loanId, "Pay Fees", "Lot Inspection Fee Paid for the due date(s) : { " + string.Join(",", DueDates) + " } " + ", Pay Date : " + lstFee[0].PaidDate.ToString("dd/MM/yyyy"), DateTime.Now);
                    (new LogAccess()).InsertLog(log);

                }
            }

            // return the value to view
            return returnValue;
        }