public async Task <IActionResult> DoctorsAppointments(SearchAppointments search)
        {
            string id    = _userManager.GetUserId(User);
            var    query = _context.Appointment.Include(a => a.Patient).Where(a => a.Doctor.User.Id == id).ToArray();

            if (search.Patient != 0)
            {
                query = query.Where(a => a.Patient.Id == search.Patient).ToArray();
            }
            if (search.DateTime != DateTime.MinValue)
            {
                query = query.Where(a => a.DateTime.Date == search.DateTime.Date).ToArray();
            }
            search.FillPatients(_context.Patients.ToArray());
            search.Appointments = query;
            return(View(search));
        }
        public async Task <IActionResult> Index(SearchAppointments search)
        {
            Doctor d = _context.Assistants.Include(a => a.Doctor).Single(a => a.User.Id == _userManager.GetUserId(User)).Doctor;

            if (d == null)
            {
                return(NotFound());
            }
            var query = _context.Appointment.Include(a => a.Patient).Where(a => a.Doctor == d).ToArray();

            if (search.Patient != 0)
            {
                query = query.Where(a => a.Patient.Id == search.Patient).ToArray();
            }
            if (search.DateTime != DateTime.MinValue)
            {
                query = query.Where(a => a.DateTime.Date == search.DateTime.Date).ToArray();
            }
            search.FillPatients(_context.Patients.ToArray());
            search.Appointments = query.OrderBy(a => a.DateTime).ToArray();
            return(View(search));
        }