public void filterRecord(int length, int masterId, int status, string property, string value, string value2, ref ScheduleDetail[] scheduleDetail)
 {
     int fetch;
     scheduleDetail = null;
     if (property.Equals("FromTime"))
     {
         StringManipulation strManipulate = new StringManipulation(value, value2, "Time");
         var records = db.ScheduleDetails.Where(a => a.FromTime >= strManipulate.timeValue && a.FromTime <= strManipulate.timeValue2)
                                         .Where(a => a.ScheduleMasterId == masterId)
                                         .Where(a => a.Status == status).Count();
         if (records > length)
         {
             if ((records - length) > pageSize)
                 fetch = pageSize;
             else
                 fetch = records - length;
             var getScheduleDetail = db.ScheduleDetails
                 .Where(a => a.FromTime >= strManipulate.timeValue && a.FromTime <= strManipulate.timeValue2)
                 .Where(a => a.ScheduleMasterId == masterId)
                 .Where(a => a.Status == status)
                 .OrderByDescending(a => a.FromTime).Skip((length)).Take(fetch).ToArray();
             scheduleDetail = getScheduleDetail;
         }
     }
     //ToTime
     else
     {
         StringManipulation strManipulate = new StringManipulation(value, value2, "Time");
         var records = db.ScheduleDetails.Where(a => a.ToTime >= strManipulate.timeValue && a.ToTime <= strManipulate.timeValue2)
                                         .Where(a => a.ScheduleMasterId == masterId)
                                         .Where(a => a.Status == status).Count();
         if (records > length)
         {
             if ((records - length) > pageSize)
                 fetch = pageSize;
             else
                 fetch = records - length;
             var getScheduleDetail = db.ScheduleDetails
                 .Where(a => a.ToTime >= strManipulate.timeValue && a.ToTime <= strManipulate.timeValue2)
                 .Where(a => a.ScheduleMasterId == masterId)
                 .Where(a => a.Status == status)
                 .OrderByDescending(a => a.FromTime).Skip((length)).Take(fetch).ToArray();
             scheduleDetail = getScheduleDetail;
         }
     }
 }
Ejemplo n.º 2
0
 public void filterRecord(int length, string property, string value, string value2, ref UserType[] userType)
 {
     /* Fields that can be filter
      * Name
      * Desription
      * Status
      */
     //Filter for a specific patient
     int fetch;
     userType = null;
     if (property.Equals("Name"))
     {
         value = value.ToLower();
         var records = db.UserTypes.Where(cs => cs.Name.ToLower().Contains(value) || cs.Name.ToLower().ToLower().Equals(value)).Count();
         if (records > length)
         {
             if ((records - length) > pageSize)
                 fetch = pageSize;
             else
                 fetch = records - length;
             var getUserType = db.UserTypes.Where(cs => cs.Name.ToLower().Contains(value) || cs.Name.ToLower().ToLower().Equals(value))
                 .OrderBy(cs => cs.Id).Skip((length)).Take(fetch).ToArray();
             userType = getUserType;
         }
     }
     else if (property.Equals("Description"))
     {
         value = value.ToLower();
         var records = db.UserTypes.Where(cs => cs.Description.ToLower().Contains(value) || cs.Description.ToLower().ToLower().Equals(value)).Count();
         if (records > length)
         {
             if ((records - length) > pageSize)
                 fetch = pageSize;
             else
                 fetch = records - length;
             var getUserType = db.UserTypes.Where(cs => cs.Description.ToLower().Contains(value) || cs.Description.ToLower().ToLower().Equals(value))
                 .OrderBy(cs => cs.Id).Skip((length)).Take(fetch).ToArray();
             userType = getUserType;
         }
     }
     //status
     else
     {
         StringManipulation strManipulate = new StringManipulation(value, value2, "Integer");
         var records = db.UserTypes.Where(cs => cs.Status == strManipulate.intValue).Count();
         if (records > length)
         {
             if ((records - length) > pageSize)
                 fetch = pageSize;
             else
                 fetch = records - length;
             var getUserType = db.UserTypes.Where(cs => cs.Status == strManipulate.intValue)
                 .OrderBy(cs => cs.Id).Skip((length)).Take(fetch).ToArray();
             userType = getUserType;
         }
     }
 }
 public void filterRecord(int length, string property, string value, string value2, ref DentalMenu[] dentalMenu)
 {
     /* Fields that can be filter
      * Name
      * Desription
      * Status
      */
     //Filter for a specific patient
     int fetch;
     dentalMenu = null;
     if (property.Equals("Name"))
     {
         value = value.ToLower();
         var records = db.DentalMenus.Where(dm => dm.Name.ToLower().Contains(value) || dm.Name.ToLower().ToLower().Equals(value)).Count();
         if (records > length)
         {
             if ((records - length) > pageSize)
                 fetch = pageSize;
             else
                 fetch = records - length;
             var getDentalMenu = db.DentalMenus.Where(dm => dm.Name.ToLower().Contains(value) || dm.Name.ToLower().ToLower().Equals(value))
                 .OrderBy(dm => dm.Id).Skip((length)).Take(fetch).ToArray();
             dentalMenu = getDentalMenu;
         }
     }
     else if (property.Equals("Description"))
     {
         value = value.ToLower();
         var records = db.DentalMenus.Where(dm => dm.Description.ToLower().Contains(value) || dm.Description.ToLower().ToLower().Equals(value)).Count();
         if (records > length)
         {
             if ((records - length) > pageSize)
                 fetch = pageSize;
             else
                 fetch = records - length;
             var getDentalMenu = db.DentalMenus.Where(dm => dm.Description.ToLower().Contains(value) || dm.Description.ToLower().ToLower().Equals(value))
                 .OrderBy(dm => dm.Id).Skip((length)).Take(fetch).ToArray();
             dentalMenu = getDentalMenu;
         }
     }
     else if (property.Equals("Url"))
     {
         value = value.ToLower();
         var records = db.DentalMenus.Where(dm => dm.Url.ToLower().Contains(value) || dm.Url.ToLower().ToLower().Equals(value)).Count();
         if (records > length)
         {
             if ((records - length) > pageSize)
                 fetch = pageSize;
             else
                 fetch = records - length;
             var getDentalMenu = db.DentalMenus.Where(dm => dm.Url.ToLower().Contains(value) || dm.Url.ToLower().ToLower().Equals(value))
                 .OrderBy(dm => dm.Id).Skip((length)).Take(fetch).ToArray();
             dentalMenu = getDentalMenu;
         }
     }
     else if (property.Equals("ParentName"))
     {
         StringManipulation strManipulate = new StringManipulation(value, value2, "Integer");
         var records = db.DentalMenus.Where(dm => dm.ParentId == strManipulate.intValue).Count();
         if (records > length)
         {
             if ((records - length) > pageSize)
                 fetch = pageSize;
             else
                 fetch = records - length;
             var getDentalMenu = db.DentalMenus.Where(dm => dm.ParentId == strManipulate.intValue)
                 .OrderBy(cs => cs.Id).Skip((length)).Take(fetch).ToArray();
             dentalMenu = getDentalMenu;
         }
     }
     //status
     else
     {
         StringManipulation strManipulate = new StringManipulation(value, value2, "Integer");
         var records = db.DentalMenus.Where(dm => dm.Status == strManipulate.intValue).Count();
         if (records > length)
         {
             if ((records - length) > pageSize)
                 fetch = pageSize;
             else
                 fetch = records - length;
             var getDentalMenu = db.DentalMenus.Where(dm => dm.Status == strManipulate.intValue)
                 .OrderBy(dm => dm.Id).Skip((length)).Take(fetch).ToArray();
             dentalMenu = getDentalMenu;
         }
     }
 }
 public void filterRecord(int length, string property, string value, string value2, ref ScheduleMaster[] scheduleMaster)
 {
     /* Fields that can be filter
      * Name
      * Desription
      * Status
      */
     //Filter for a specific patient
     int fetch;
     scheduleMaster = null;
     if (property.Equals("Date"))
     {
         StringManipulation strManipulate = new StringManipulation(value, value2, "Date");
         strManipulate.dateValue2 = strManipulate.dateValue2.AddHours(11);
         var records = db.ScheduleMasters.Where(sm => sm.Date >= strManipulate.dateValue && sm.Date <= strManipulate.dateValue2).Count();
         if (records > length)
         {
             if ((records - length) > pageSize)
                 fetch = pageSize;
             else
                 fetch = records - length;
             var getScheduleMaster = db.ScheduleMasters.Where(sm => sm.Date >= strManipulate.dateValue && sm.Date <= strManipulate.dateValue2)
                                                       .Include(sm => sm.UserInformation).Where(ui => ui.UserInformation.User.UserTypeId == 4)
                                                       .OrderByDescending(sm => sm.Date).Skip((length)).Take(fetch).AsNoTracking().ToArray();
             scheduleMaster = getScheduleMaster;
         }
     }
     else if (property.Equals("DentistFirstName"))
     {
         value = value.ToLower();
         var records = db.ScheduleMasters.Where(sm => sm.UserInformation.FirstName.ToLower().Contains(value) || sm.UserInformation.FirstName.ToLower().ToLower().Equals(value)).Count();
         if (records > length)
         {
             if ((records - length) > pageSize)
                 fetch = pageSize;
             else
                 fetch = records - length;
             var getScheduleMaster = db.ScheduleMasters.Where(sm => sm.UserInformation.FirstName.ToLower().Contains(value) || sm.UserInformation.FirstName.ToLower().ToLower().Equals(value))
                                                       .Include(sm => sm.UserInformation).Where(ui => ui.UserInformation.User.UserTypeId == 4)
                                                       .OrderBy(sm => sm.Id).Skip((length)).Take(fetch).AsNoTracking().ToArray();
             scheduleMaster = getScheduleMaster;
         }
     }
     else if (property.Equals("DentistMiddleName"))
     {
         value = value.ToLower();
         var records = db.ScheduleMasters.Where(sm => sm.UserInformation.MiddleName.ToLower().Contains(value) || sm.UserInformation.MiddleName.ToLower().ToLower().Equals(value)).Count();
         if (records > length)
         {
             if ((records - length) > pageSize)
                 fetch = pageSize;
             else
                 fetch = records - length;
             var getScheduleMaster = db.ScheduleMasters.Where(sm => sm.UserInformation.MiddleName.ToLower().Contains(value) || sm.UserInformation.MiddleName.ToLower().ToLower().Equals(value))
                                                       .Include(sm => sm.UserInformation).Where(ui => ui.UserInformation.User.UserTypeId == 4)
                                                       .OrderBy(sm => sm.Id).Skip((length)).Take(fetch).AsNoTracking().ToArray();
             scheduleMaster = getScheduleMaster;
         }
     }
     else if (property.Equals("DentistLastName"))
     {
         value = value.ToLower();
         var records = db.ScheduleMasters.Where(sm => sm.UserInformation.LastName.ToLower().Contains(value) || sm.UserInformation.LastName.ToLower().ToLower().Equals(value)).Count();
         if (records > length)
         {
             if ((records - length) > pageSize)
                 fetch = pageSize;
             else
                 fetch = records - length;
             var getScheduleMaster = db.ScheduleMasters.Where(sm => sm.UserInformation.LastName.ToLower().Contains(value) || sm.UserInformation.LastName.ToLower().ToLower().Equals(value))
                                                       .Include(sm => sm.UserInformation).Where(ui => ui.UserInformation.User.UserTypeId == 4)
                                                       .OrderBy(sm => sm.Id).Skip((length)).Take(fetch).AsNoTracking().ToArray();
             scheduleMaster = getScheduleMaster;
         }
     }
     //status
     else
     {
         StringManipulation strManipulate = new StringManipulation(value, value2, "Integer");
         var records = db.ScheduleMasters.Where(sm => sm.Status == strManipulate.intValue).Count();
         if (records > length)
         {
             if ((records - length) > pageSize)
                 fetch = pageSize;
             else
                 fetch = records - length;
             var getScheduleMaster = db.ScheduleMasters.Where(sm => sm.Status == strManipulate.intValue)
                                                       .Include(sm => sm.UserInformation).Where(ui => ui.UserInformation.User.UserTypeId == 4)
                                                       .OrderBy(sm => sm.Id).Skip((length)).Take(fetch).AsNoTracking().ToArray();
             scheduleMaster = getScheduleMaster;
         }
     }
 }
 //Filtering for Normal Appointments
 public void filterRecord(int length, string property, string value, string value2, ref PatientDiagnosisHistoryMaster[] diagnosisHistoryMaster)
 {
     /* Fields that can be filter
      * Patient First Name
      * Patient Middle Name
      * Patient Last Name
      * Appointment Date
      * Appointment From Time
      * Appointment To Time
      */
     //Filter for a specific patient
     int fetch;
     diagnosisHistoryMaster = null;
     if (property.Equals("AppointmentDate"))
     {
         StringManipulation strManipulate = new StringManipulation(value, value2, "Date");
         var records = db.PatientDiagnosisHistoryMasters.Where(pdhm => (pdhm.Appointment.ScheduleMaster.Date >= strManipulate.dateValue && pdhm.Appointment.ScheduleMaster.Date <= strManipulate.dateValue2)
                                                               && pdhm.Status != 0).Count();
         if (records > length)
         {
             if ((records - length) > pageSize)
                 fetch = pageSize;
             else
                 fetch = records - length;
             var getDiagnosisHistoryMaster = db.PatientDiagnosisHistoryMasters
                 .Include(pdhm => pdhm.User.UserInformations)
                 .Include(pdhm => pdhm.Appointment.ScheduleMaster.UserInformation)
                 .Include(pdhm => pdhm.Appointment.ScheduleMaster)
                 .Include(pdhm => pdhm.Appointment.ScheduleDetail)
                 .Where(pdhm => (pdhm.Appointment.ScheduleMaster.Date >= strManipulate.dateValue && pdhm.Appointment.ScheduleMaster.Date <= strManipulate.dateValue2)
                                                     && pdhm.Status != 0).OrderByDescending(pdhm => pdhm.Appointment.ScheduleMaster.Date).Skip((length)).Take(fetch).ToArray();
             diagnosisHistoryMaster = getDiagnosisHistoryMaster;
         }
     }
     else if (property.Equals("ScheduledFromTime"))
     {
         StringManipulation strManipulate = new StringManipulation(value, value2, "Time");
         var records = db.PatientDiagnosisHistoryMasters.Where(pdhm => (pdhm.Appointment.ScheduleDetail.FromTime >= strManipulate.timeValue && pdhm.Appointment.ScheduleDetail.ToTime <= strManipulate.timeValue2)
                                                               && pdhm.Status != 0).Count();
         if (records > length)
         {
             if ((records - length) > pageSize)
                 fetch = pageSize;
             else
                 fetch = records - length;
             var getDiagnosisHistoryMaster = db.PatientDiagnosisHistoryMasters
                 .Include(pdhm => pdhm.User.UserInformations)
                 .Include(pdhm => pdhm.Appointment.ScheduleMaster)
                 .Include(pdhm => pdhm.Appointment.ScheduleDetail)
                 .Where(pdhm => (pdhm.Appointment.ScheduleDetail.FromTime >= strManipulate.timeValue && pdhm.Appointment.ScheduleDetail.ToTime <= strManipulate.timeValue2)
                                                     && pdhm.Status != 0).OrderByDescending(pdhm => pdhm.Appointment.ScheduleMaster.Date).Skip((length)).Take(fetch).ToArray();
             diagnosisHistoryMaster = getDiagnosisHistoryMaster;
         }
     }
     else if (property.Equals("ScheduledToTime"))
     {
         StringManipulation strManipulate = new StringManipulation(value, value2, "Time");
         var records = db.PatientDiagnosisHistoryMasters.Where(pdhm => (pdhm.Appointment.ScheduleDetail.FromTime >= strManipulate.timeValue && pdhm.Appointment.ScheduleDetail.ToTime <= strManipulate.timeValue2)
                                                               && pdhm.Status != 0).Count();
         if (records > length)
         {
             if ((records - length) > pageSize)
                 fetch = pageSize;
             else
                 fetch = records - length;
             var getDiagnosisHistoryMaster = db.PatientDiagnosisHistoryMasters
                 .Include(pdhm => pdhm.User.UserInformations)
                 .Include(pdhm => pdhm.Appointment.ScheduleMaster.UserInformation)
                 .Include(pdhm => pdhm.Appointment.ScheduleMaster)
                 .Include(pdhm => pdhm.Appointment.ScheduleDetail)
                 .Where(pdhm => (pdhm.Appointment.ScheduleDetail.FromTime >= strManipulate.timeValue && pdhm.Appointment.ScheduleDetail.ToTime <= strManipulate.timeValue2)
                                                     && pdhm.Status != 0).OrderByDescending(pdhm => pdhm.Appointment.ScheduleMaster.Date).Skip((length)).Take(fetch).ToArray();
             diagnosisHistoryMaster = getDiagnosisHistoryMaster;
         }
     }
     else if (property.Equals("PatientFirstName"))
     {
         value = value.ToLower();
         var records = db.PatientDiagnosisHistoryMasters.Where(pdhm => (pdhm.User.UserInformations.FirstOrDefault().FirstName.ToLower().Contains(value)
                                                   || pdhm.User.UserInformations.FirstOrDefault().FirstName.ToLower().Equals(value))
                                                   && pdhm.Status != 0).Count();
         if (records > length)
         {
             if ((records - length) > pageSize)
                 fetch = pageSize;
             else
                 fetch = records - length;
             var getDiagnosisHistoryMaster = db.PatientDiagnosisHistoryMasters
                 .Include(pdhm => pdhm.User.UserInformations)
                 .Include(pdhm => pdhm.Appointment.ScheduleMaster)
                 .Include(pdhm => pdhm.Appointment.ScheduleDetail)
                 .Where(pdhm => (pdhm.Appointment.User.UserInformations.FirstOrDefault().FirstName.ToLower().Contains(value)
                                 || pdhm.Appointment.User.UserInformations.FirstOrDefault().FirstName.ToLower().Equals(value))
                                 && pdhm.Status != 0).OrderByDescending(pdhm => pdhm.Appointment.ScheduleDetail.FromTime).Skip((length)).Take(fetch).ToArray();
             diagnosisHistoryMaster = getDiagnosisHistoryMaster;
         }
     }
     else if (property.Equals("PatientLastName"))
     {
         value = value.ToLower();
         var records = db.PatientDiagnosisHistoryMasters.Where(pdhm => (pdhm.Appointment.User.UserInformations.FirstOrDefault().LastName.ToLower().Contains(value)
                                                   || pdhm.Appointment.User.UserInformations.FirstOrDefault().LastName.ToLower().Equals(value))
                                                   && pdhm.Status != 0).Count();
         if (records > length)
         {
             if ((records - length) > pageSize)
                 fetch = pageSize;
             else
                 fetch = records - length;
             var getDiagnosisHistoryMaster = db.PatientDiagnosisHistoryMasters
                 .Include(pdhm => pdhm.User.UserInformations)
                 .Include(pdhm => pdhm.Appointment.ScheduleMaster)
                 .Include(pdhm => pdhm.Appointment.ScheduleDetail)
                 .Where(pdhm => (pdhm.Appointment.User.UserInformations.FirstOrDefault().LastName.ToLower().Contains(value)
                                 || pdhm.Appointment.User.UserInformations.FirstOrDefault().LastName.ToLower().Equals(value))
                                 && pdhm.Status != 0).OrderByDescending(pdhm => pdhm.Appointment.ScheduleDetail.FromTime).Skip((length)).Take(fetch).ToArray();
             diagnosisHistoryMaster = getDiagnosisHistoryMaster;
         }
     }
     else if (property.Equals("PatientMiddleName"))
     {
         value = value.ToLower();
         var records = db.PatientDiagnosisHistoryMasters.Where(pdhm => (pdhm.Appointment.User.UserInformations.FirstOrDefault().MiddleName.ToLower().Contains(value)
                                                   || pdhm.Appointment.User.UserInformations.FirstOrDefault().MiddleName.ToLower().Equals(value))
                                                   && pdhm.Status != 0).Count();
         if (records > length)
         {
             if ((records - length) > pageSize)
                 fetch = pageSize;
             else
                 fetch = records - length;
             var getDiagnosisHistoryMaster = db.PatientDiagnosisHistoryMasters
                 .Include(pdhm => pdhm.User.UserInformations)
                 .Include(pdhm => pdhm.Appointment.ScheduleMaster.UserInformation)
                 .Include(pdhm => pdhm.Appointment.ScheduleMaster)
                 .Include(pdhm => pdhm.Appointment.ScheduleDetail)
                 .Where(pdhm => (pdhm.Appointment.User.UserInformations.FirstOrDefault().MiddleName.ToLower().Contains(value)
                                 || pdhm.Appointment.User.UserInformations.FirstOrDefault().MiddleName.ToLower().Equals(value))
                                 && pdhm.Status != 0).OrderByDescending(pdhm => pdhm.Appointment.ScheduleDetail.FromTime).Skip((length)).Take(fetch).ToArray();
             diagnosisHistoryMaster = getDiagnosisHistoryMaster;
         }
     }
     else if (property.Equals("DentistFirstName"))
     {
         value = value.ToLower();
         var records = db.PatientDiagnosisHistoryMasters.Where(pdhm => (pdhm.Appointment.ScheduleMaster.UserInformation.FirstName.ToLower().Contains(value)
                                                   || pdhm.Appointment.ScheduleMaster.UserInformation.FirstName.ToLower().Equals(value))
                                                   && pdhm.Status != 0).Count();
         if (records > length)
         {
             if ((records - length) > pageSize)
                 fetch = pageSize;
             else
                 fetch = records - length;
             var getDiagnosisHistoryMaster = db.PatientDiagnosisHistoryMasters
                 .Include(pdhm => pdhm.User.UserInformations)
                 .Include(pdhm => pdhm.Appointment.ScheduleMaster)
                 .Include(pdhm => pdhm.Appointment.ScheduleDetail)
                 .Where(pdhm => (pdhm.Appointment.ScheduleMaster.UserInformation.FirstName.ToLower().Contains(value)
                                 || pdhm.Appointment.ScheduleMaster.UserInformation.FirstName.ToLower().Equals(value))
                                 && pdhm.Status != 0).OrderByDescending(pdhm => pdhm.Appointment.ScheduleDetail.FromTime).Skip((length)).Take(fetch).ToArray();
             diagnosisHistoryMaster = getDiagnosisHistoryMaster;
         }
     }
     else if (property.Equals("DentistLastName"))
     {
         value = value.ToLower();
         var records = db.PatientDiagnosisHistoryMasters.Where(pdhm => (pdhm.Appointment.ScheduleMaster.UserInformation.LastName.ToLower().Contains(value)
                                                   || pdhm.Appointment.ScheduleMaster.UserInformation.LastName.ToLower().Equals(value))
                                                   && pdhm.Status != 0).Count();
         if (records > length)
         {
             if ((records - length) > pageSize)
                 fetch = pageSize;
             else
                 fetch = records - length;
             var getDiagnosisHistoryMaster = db.PatientDiagnosisHistoryMasters
                 .Include(pdhm => pdhm.User.UserInformations)
                 .Include(pdhm => pdhm.Appointment.ScheduleMaster)
                 .Include(pdhm => pdhm.Appointment.ScheduleDetail)
                 .Where(pdhm => (pdhm.Appointment.ScheduleMaster.UserInformation.LastName.ToLower().Contains(value)
                                 || pdhm.Appointment.ScheduleMaster.UserInformation.LastName.ToLower().Equals(value))
                                 && pdhm.Status != 0).OrderByDescending(pdhm => pdhm.Appointment.ScheduleDetail.FromTime).Skip((length)).Take(fetch).ToArray();
             diagnosisHistoryMaster = getDiagnosisHistoryMaster;
         }
     }
     //Dentist Middle Name
     else
     {
         value = value.ToLower();
         var records = db.PatientDiagnosisHistoryMasters.Where(pdhm => (pdhm.Appointment.ScheduleMaster.UserInformation.MiddleName.ToLower().Contains(value)
                                                   || pdhm.Appointment.ScheduleMaster.UserInformation.MiddleName.ToLower().Equals(value))
                                                   && pdhm.Status != 0).Count();
         if (records > length)
         {
             if ((records - length) > pageSize)
                 fetch = pageSize;
             else
                 fetch = records - length;
             var getDiagnosisHistoryMaster = db.PatientDiagnosisHistoryMasters
                 .Include(pdhm => pdhm.User.UserInformations)
                 .Include(pdhm => pdhm.Appointment.ScheduleMaster)
                 .Include(pdhm => pdhm.Appointment.ScheduleDetail)
                 .Where(pdhm => (pdhm.Appointment.ScheduleMaster.UserInformation.MiddleName.ToLower().Contains(value)
                                 || pdhm.Appointment.ScheduleMaster.UserInformation.MiddleName.ToLower().Equals(value))
                                 && pdhm.Status != 0).OrderByDescending(pdhm => pdhm.Appointment.ScheduleDetail.FromTime).Skip((length)).Take(fetch).ToArray();
             diagnosisHistoryMaster = getDiagnosisHistoryMaster;
         }
     }
     if (diagnosisHistoryMaster != null)
     {
         for (int i = 0; i < diagnosisHistoryMaster.Length; i++)
         {
             diagnosisHistoryMaster[i].User.Appointments = null;
             diagnosisHistoryMaster[i].User.Appointments = null;
             diagnosisHistoryMaster[i].User.Messages = null;
             diagnosisHistoryMaster[i].User.Messages1 = null;
             diagnosisHistoryMaster[i].User.Notifications = null;
             diagnosisHistoryMaster[i].User.PatientDentalHistories = null;
             diagnosisHistoryMaster[i].User.PatientDiagnosisHistoryMasters = null;
             diagnosisHistoryMaster[i].User.PatientMedicalHistories = null;
             diagnosisHistoryMaster[i].User.UserType = null;
             diagnosisHistoryMaster[i].Appointment.ScheduleMaster.Appointments = null;
             diagnosisHistoryMaster[i].Appointment.ScheduleMaster.ScheduleDetails = null;
             diagnosisHistoryMaster[i].Appointment.ScheduleDetail.Appointments = null;
             diagnosisHistoryMaster[i].Appointment.ScheduleDetail.ScheduleMaster = null;
             diagnosisHistoryMaster[i].Appointment.ScheduleMaster.UserInformation.PatientMouths = null;
             diagnosisHistoryMaster[i].Appointment.ScheduleMaster.UserInformation.ScheduleMasters = null;
             diagnosisHistoryMaster[i].Appointment.ScheduleMaster.UserInformation.CivilStatu = null;
             diagnosisHistoryMaster[i].Appointment.ScheduleMaster.UserInformation.User = null;
             foreach (var ui in diagnosisHistoryMaster[i].User.UserInformations)
             {
                 ui.CivilStatu = null;
                 ui.PatientMouths = null;
                 ui.ScheduleMasters = null;
             }
         }
     }
 }
Ejemplo n.º 6
0
 public void filterRecord(int length, string property, string value, string value2, ref User[] users)
 {
     /* Fields that can be filter
      * Name
      * Desription
      * Status
      */
     //Filter for a specific patient
     int fetch;
     users = null;
     if (property.Equals("UserName"))
     {
         value = value.ToLower();
         var records = db.Users.Where(u => u.Username.ToLower().Contains(value) || u.Username.ToLower().Equals(value)).Count();
         if (records > length)
         {
             if ((records - length) > pageSize)
                 fetch = pageSize;
             else
                 fetch = records - length;
             var getUsers = db.Users.Include(u => u.UserInformations)
                                    .Include(u => u.UserType)
                                    .Where(u => u.Username.ToLower().Contains(value) || u.Username.ToLower().Equals(value))
                                    .OrderBy(u => u.Id).Skip((length)).Take(fetch).AsNoTracking().ToArray();
             users = getUsers;
         }
     }
     else if (property.Equals("FirstName"))
     {
         value = value.ToLower();
         var records = db.Users.Where(u => u.UserInformations.Where( ui => ui.FirstName.ToLower().Contains(value)).Count() > 0
                                        || u.UserInformations.Where( ui => ui.FirstName.ToLower().Equals(value)).Count() > 0).Count();
         if (records > length)
         {
             if ((records - length) > pageSize)
                 fetch = pageSize;
             else
                 fetch = records - length;
             var getUsers = db.Users
                              .Include(u => u.UserInformations)
                              .Include(u => u.UserType)
                              .Where(u => u.UserInformations.Where(ui => ui.FirstName.ToLower().Contains(value)).Count() > 0
                                     || u.UserInformations.Where(ui => ui.FirstName.ToLower().Equals(value)).Count() > 0)
                              .OrderBy(u => u.Id).Skip((length)).Take(fetch).AsNoTracking().ToArray();
             users = getUsers;
         }
     }
     else if (property.Equals("MiddleName"))
     {
         value = value.ToLower();
         var records = db.Users.Where(u => u.UserInformations.Where(ui => ui.MiddleName.ToLower().Contains(value)).Count() > 0
                                        || u.UserInformations.Where(ui => ui.MiddleName.ToLower().Equals(value)).Count() > 0).Count();
         if (records > length)
         {
             if ((records - length) > pageSize)
                 fetch = pageSize;
             else
                 fetch = records - length;
             var getUsers = db.Users
                              .Include(u => u.UserInformations)
                              .Include(u => u.UserType)
                              .Where(u => u.UserInformations.Where(ui => ui.MiddleName.ToLower().Contains(value)).Count() > 0
                                     || u.UserInformations.Where(ui => ui.MiddleName.ToLower().Equals(value)).Count() > 0)
                              .OrderBy(u => u.Id).Skip((length)).Take(fetch).AsNoTracking().ToArray();
             users = getUsers;
         }
     }
     else if (property.Equals("LastName"))
     {
         value = value.ToLower();
         var records = db.Users.Where(u => u.UserInformations.Where(ui => ui.LastName.ToLower().Contains(value)).Count() > 0
                                        || u.UserInformations.Where(ui => ui.LastName.ToLower().Equals(value)).Count() > 0).Count();
         if (records > length)
         {
             if ((records - length) > pageSize)
                 fetch = pageSize;
             else
                 fetch = records - length;
             var getUsers = db.Users
                              .Include(u => u.UserInformations)
                              .Include(u => u.UserType)
                              .Where(u => u.UserInformations.Where(ui => ui.LastName.ToLower().Contains(value)).Count() > 0
                                     || u.UserInformations.Where(ui => ui.LastName.ToLower().Equals(value)).Count() > 0)
                              .OrderBy(u => u.Id).Skip((length)).Take(fetch).AsNoTracking().ToArray();
             users = getUsers;
         }
     }
     else if (property.Equals("EmailAddress"))
     {
         value = value.ToLower();
         var records = db.Users.Where(u => u.UserInformations.Where(ui => ui.EmailAddress.ToLower().Contains(value)).Count() > 0
                                        || u.UserInformations.Where(ui => ui.EmailAddress.ToLower().Equals(value)).Count() > 0).Count();
         if (records > length)
         {
             if ((records - length) > pageSize)
                 fetch = pageSize;
             else
                 fetch = records - length;
             var getUsers = db.Users
                              .Include(u => u.UserInformations)
                              .Include(u => u.UserType)
                              .Where(u => u.UserInformations.Where(ui => ui.EmailAddress.ToLower().Contains(value)).Count() > 0
                                     || u.UserInformations.Where(ui => ui.EmailAddress.ToLower().Equals(value)).Count() > 0)
                              .OrderBy(u => u.Id).Skip((length)).Take(fetch).AsNoTracking().ToArray();
             users = getUsers;
         }
     }
     else if (property.Equals("Gender"))
     {
         value = value.ToLower();
         var records = db.Users.Where(u => u.UserInformations.Where(ui => ui.Gender.ToLower().Contains(value)).Count() > 0
                                        || u.UserInformations.Where(ui => ui.Gender.ToLower().Equals(value)).Count() > 0).Count();
         if (records > length)
         {
             if ((records - length) > pageSize)
                 fetch = pageSize;
             else
                 fetch = records - length;
             var getUsers = db.Users
                              .Include(u => u.UserInformations)
                              .Include(u => u.UserType)
                              .Where(u => u.UserInformations.Where(ui => ui.Gender.ToLower().Contains(value)).Count() > 0
                                     || u.UserInformations.Where(ui => ui.Gender.ToLower().Equals(value)).Count() > 0)
                              .OrderBy(u => u.Id).Skip((length)).Take(fetch).AsNoTracking().ToArray();
             users = getUsers;
         }
     }
     //status
     else
     {
         StringManipulation strManipulate = new StringManipulation(value, value2, "Integer");
         var records = db.Users.Where(u => u.Status == strManipulate.intValue).Count();
         if (records > length)
         {
             if ((records - length) > pageSize)
                 fetch = pageSize;
             else
                 fetch = records - length;
             var getUsers = db.Users
                              .Include(u => u.UserInformations)
                              .Include(u => u.UserType)
                              .Where(u => u.Status == strManipulate.intValue)
                              .OrderBy(u => u.Id).Skip((length)).Take(fetch).AsNoTracking().ToArray();
             users = getUsers;
         }
     }
 }