public async Task <IActionResult> SuccessFullAppointments(string searchName = null, string searchEmail = null, string searchPhone = null, string searchDate = null) { //var claimsIdentity = (ClaimsIdentity)this.User.Identity; //var claim = claimsIdentity.FindFirst(ClaimTypes.NameIdentifier); AppointmentViewModel appointmentVm = new AppointmentViewModel() { Appointments = new List <Appointments>() }; if (orm == 1) { appointmentVm.Appointments = qdb.SucAppointments(); } else { appointmentVm.Appointments = await _db.Appointments.Where(e => e.IsConfirmed == true).ToListAsync(); } //if (User.IsInRole(SD.AdminEndUser)) //{ // appointmentVm.Appointments = // appointmentVm.Appointments.Where(e => e.SalesPersonId == claim.Value).ToList(); //} if (searchName != null) { appointmentVm.Appointments = appointmentVm.Appointments .Where(e => e.CustomerName.ToLower().Contains(searchName.ToLower())).ToList(); } if (searchEmail != null) { appointmentVm.Appointments = appointmentVm.Appointments .Where(e => e.CustomerEmail.ToLower().Contains(searchEmail.ToLower())).ToList(); } if (searchPhone != null) { appointmentVm.Appointments = appointmentVm.Appointments .Where(e => e.CustomerNumber.ToLower().Contains(searchPhone.ToLower())).ToList(); } if (searchDate != null) { try { DateTime date = Convert.ToDateTime(searchDate); appointmentVm.Appointments = appointmentVm.Appointments .Where(e => e.AppointmentDate.ToShortDateString().Equals(date.ToShortDateString())).ToList(); } catch (Exception e) { } } return(View(appointmentVm)); }