//Action method that will be used to display all the cases
        //this action will also be used to filter searches according to either the status or the case number
        public IActionResult Index(int status, int caseNumber)
        {
            ViewBag.Status = new SelectList(context.CaseStatuses.ToList <CaseStatus>(), "CaseStatusID", "Name");
            var c = new List <Case>();

            //check if the status argument is given so that the list can be filtered by the status
            //Else if the case number arfument so that the list can filter using the casenumber
            if (status > 0)
            {
                return(View(caseOps.SearchByStatus(status)));
            }
            else if (caseNumber > 0)
            {
                c.Add(caseOps.SearchByCaseNumber(caseNumber));
                return(View(c));
            }
            return(View(caseOps.GetAll()));
        }
        public IActionResult Index(string pin, int caseNumber)
        {
            List <FinePayment> _finePay = new List <FinePayment>();

            if (pin != null && caseNumber != 0)
            {
                var _case = caseOps.SearchByCaseNumber(caseNumber);
                if (_case != null)
                {
                    var _fine = fineOps.GetAll().Where(f => f.Offender.PIN == pin).SingleOrDefault <Fine>();
                    if (_fine != null)
                    {
                        var caseOffender = context.CaseOffenders.Where <CaseOffender>(co => co.CaseID == _case.CaseID && co.OffenderID == _fine.OffenderID).SingleOrDefault <CaseOffender>();
                        if (caseOffender != null)
                        {
                            var userid        = context.Users.Where(u => u.UserName == User.Identity.Name).FirstOrDefault();
                            var _amortization = amortization.GetAll().Where(am => am.CaseID == _case.CaseID && am.FineID == _fine.FineID).SingleOrDefault <Amortization>();
                            var fnp           = new FinePayment
                            {
                                RelativeID         = context.Relatives.Where(r => r.IdentityUserID == userid.Id).FirstOrDefault <Relative>().RelativeID,
                                FineID             = _fine.FineID,
                                AmortizationID     = _amortization.AmortizationID,
                                AmortizationAmount = _amortization.AmortizationAmount,
                                AmountPayable      = amortizationCalculate.AmountPayable(_case, _fine),
                                Fine         = _fine,
                                Amortization = _amortization,
                                Relative     = context.Relatives.Where(r => r.IdentityUserID == userid.Id).FirstOrDefault <Relative>()
                            };
                            _finePay.Add(fnp);



                            return(View(_finePay));
                        }
                        else
                        {
                            ViewBag.Message     = "Specified Offender was not found in the specified case";
                            ViewBag.MessageType = "Warining";

                            return(View(_finePay));
                        }
                    }
                    else
                    {
                        ViewBag.Message     = "Please enter a valid Offender Pin: Pin not found Or This Fine you're searching has been Paid";
                        ViewBag.MessageType = "Warining";

                        return(View(_finePay));
                    }
                }
                else
                {
                    ViewBag.Message     = "Please enter a valid Case Number: Case number was not found";
                    ViewBag.MessageType = "Warining";

                    return(View(_finePay));
                }

                //return View();
            }
            else
            {
                ViewBag.Message     = "Please fill in the Case Number and the offender's PIN ";
                ViewBag.MessageType = "Warining";
                return(View(_finePay));
            }
        }