public IEnumerable <R_Volunteer> GetVolunteerListAdvancedSearch( string name , int?gender , System.DateTime?birthDateFrom , System.DateTime?birthDateTo , string occupation , string employer , string phone , string email , string identityCardNumber , int?countryId , string friendOrFamilyContact , int?photo , int?addressId , bool?hasCar , bool?hasDriverLicense , bool?hasBike , string vehicleMake , string vehicleModel , bool?active ) { IEnumerable <R_Volunteer> results = null; var sql = PetaPoco.Sql.Builder .Select("*") .From("R_Volunteer") .Where("IsDeleted = 0" + (name != null ? " and Name like '%" + name + "%'" : "") + (gender != null ? " and Gender like '%" + gender + "%'" : "") + (birthDateFrom != null ? " and BirthDate >= '" + birthDateFrom.Value.ToShortDateString() + "'" : "") + (birthDateTo != null ? " and BirthDate <= '" + birthDateTo.Value.ToShortDateString() + "'" : "") + (occupation != null ? " and Occupation like '%" + occupation + "%'" : "") + (employer != null ? " and Employer like '%" + employer + "%'" : "") + (phone != null ? " and Phone like '%" + phone + "%'" : "") + (email != null ? " and Email like '%" + email + "%'" : "") + (identityCardNumber != null ? " and IdentityCardNumber like '%" + identityCardNumber + "%'" : "") + (countryId != null ? " and CountryId like '%" + countryId + "%'" : "") + (friendOrFamilyContact != null ? " and FriendOrFamilyContact like '%" + friendOrFamilyContact + "%'" : "") + (photo != null ? " and Photo like '%" + photo + "%'" : "") + (addressId != null ? " and AddressId like '%" + addressId + "%'" : "") + (hasCar != null ? " and HasCar = " + (hasCar == true ? "1" : "0") : "") + (hasDriverLicense != null ? " and HasDriverLicense = " + (hasDriverLicense == true ? "1" : "0") : "") + (hasBike != null ? " and HasBike = " + (hasBike == true ? "1" : "0") : "") + (vehicleMake != null ? " and VehicleMake like '%" + vehicleMake + "%'" : "") + (vehicleModel != null ? " and VehicleModel like '%" + vehicleModel + "%'" : "") + (active != null ? " and Active = " + (active == true ? "1" : "0") : "") ) ; results = R_Volunteer.Query(sql); return(results); }
public IEnumerable <R_Volunteer> GetVolunteers() { IEnumerable <R_Volunteer> results = null; var sql = PetaPoco.Sql.Builder .Select("*") .From("R_Volunteer") .Where("IsDeleted = 0") ; results = R_Volunteer.Query(sql); return(results); }