/*

         Frontend page: Fee Page
         Title: get fees by selected date
         Designed: Nadeeka
         User story:
         Developed: Nadeeka
         Date created: 4/25/2016

      */
        
        public ActionResult SearchFee(string identificationNumber, string year, string make, string vehicleModel, FeesModel CurtailmentList)
        {
            List<Fees> SearchList = new List<Fees>();

            // if fee list exists on session
            if (Session["feeList"] != null)
            {
                List<Fees> feeModel = (List<Fees>)Session["feeList"];

                // if atleast one searching criteria matches -- do search
                if (((!string.IsNullOrEmpty(identificationNumber)) || (!string.IsNullOrEmpty(year)) || (!string.IsNullOrEmpty(make)) || (!string.IsNullOrEmpty(vehicleModel))))
                {
                    //search through list of elements
                    Search sc = new Search();

                    SearchList = sc.GetSearchFeeList(feeModel, identificationNumber.Trim().ToLower(), year.Trim().ToLower(), make.Trim().ToLower(), vehicleModel.Trim().ToLower()); // take filtered elements
                     // pass the list to view
                    return PartialView(SearchList);
                }

                // if no searching criteria matched -- retunt empty list
                else
                {

                    return PartialView(SearchList);
                }
            }

            // if fee list not exist on session -- return empty list
            else
            {

                return PartialView(SearchList);
            }
        }
        /*

          Frontend page: Fee Page
          Title: get fees by selected date
          Designed: Nadeeka
          User story:
          Developed: Nadeeka
          Date created: 4/21/2016

       */
        
        public ActionResult PayFeesForSelectedDueDate(DateTime dueDate, string type)
        {
                LoanSetupStep1 loanDetails = new LoanSetupStep1();
                loanDetails = (new LoanSetupAccess()).GetLoanDetailsByLoanCode(Session["loanCode"].ToString()); // take the loan detail of selected loan
                // pass the loan details to the view
                ViewBag.loanDetails = loanDetails;

                FeeAccess feeAccess = new FeeAccess();
                List<Fees> lstFee = feeAccess.GetFeesByDueDate(loanDetails.loanId, dueDate, type); // get fees list by duedate and type of fee
                FeesModel feeModel = new FeesModel();
                feeModel.FeeModelList = new List<Fees>();
                feeModel.Type = type;

                // if list exists, add to model and session for searching
                if (lstFee != null && lstFee.Count > 0)
                {
                    feeModel.FeeModelList.AddRange(lstFee);
                    Session["feeList"] = feeModel.FeeModelList;
                   
                }

               // return partial view of selected fee page
                return PartialView(feeModel);
                

                        
        }