public ActionResult ManageInvoices(int id = 0) { int InvoiceCounter = patientBusinessLayer.GetNumberOfInvoices(); invoiceListViewModel = new List <InvoiceViewModel>(); if (InvoiceCounter != 0) { if (id != 0) { int PatientId = (int)id; List <Appointment> appointments = patientBusinessLayer.GetPatientAppointments(PatientId); invoiceListViewModel = FetchInvoicesByAppointmentId(appointments); return(View(invoiceListViewModel)); } else { List <Appointment> appointments = patientBusinessLayer.GetAppointments(); invoiceListViewModel = FetchInvoicesByAppointmentId(appointments); return(View(invoiceListViewModel)); } } return(View(invoiceListViewModel)); }