public IQueryable <Appointment> FilterAppointments(AppointmentSearchVM searchModel) { var result = _context.Appointments.Include(p => p.Patient).Include(d => d.Doctor).AsQueryable(); if (searchModel != null) { if (!string.IsNullOrWhiteSpace(searchModel.Name)) { result = result.Where(a => a.Doctor.Name == searchModel.Name); } if (!string.IsNullOrWhiteSpace(searchModel.Option)) { if (searchModel.Option == "ThisMonth") { result = result.Where(x => x.StartDateTime.Year == DateTime.Now.Year && x.StartDateTime.Month == DateTime.Now.Month); } else if (searchModel.Option == "Pending") { result = result.Where(x => x.Status == false); } else if (searchModel.Option == "Approved") { result = result.Where(x => x.Status); } } } return(result); }
public ActionResult TestAppointment(AppointmentSearchVM viewModel) { var filter = _unitOfWork.Appointments.FilterAppointments(viewModel); return(PartialView("_Appointments", filter)); }
public ActionResult Appointments(AppointmentSearchVM viewModel) { var filter = _unitOfWork.Appointments.FilterAppointments(viewModel); return(View(filter)); }