public IEnumerable <R_PlannedRoute> GetPlannedRoutes() { IEnumerable <R_PlannedRoute> results = null; var sql = PetaPoco.Sql.Builder .Select("*") .From("R_PlannedRoute") .Where("IsDeleted = 0") ; results = R_PlannedRoute.Query(sql); return(results); }
public IEnumerable <R_PlannedRoute> GetPlannedRouteListAdvancedSearch( string name , int?routeTypeId , int?transportTypeId , string description , System.DateTime?startHourFrom , System.DateTime?startHourTo , int?estimatedDuration , double?totalDistance , string routeDayOfTheWeek , bool?active ) { IEnumerable <R_PlannedRoute> results = null; var sql = PetaPoco.Sql.Builder .Select("*") .From("R_PlannedRoute") .Where("IsDeleted = 0" + (name != null ? " and Name like '%" + name + "%'" : "") + (routeTypeId != null ? " and RouteTypeId like '%" + routeTypeId + "%'" : "") + (transportTypeId != null ? " and TransportTypeId like '%" + transportTypeId + "%'" : "") + (description != null ? " and Description like '%" + description + "%'" : "") + (startHourFrom != null ? " and StartHour >= '" + startHourFrom.Value.ToShortDateString() + "'" : "") + (startHourTo != null ? " and StartHour <= '" + startHourTo.Value.ToShortDateString() + "'" : "") + (estimatedDuration != null ? " and EstimatedDuration like '%" + estimatedDuration + "%'" : "") + (totalDistance != null ? " and TotalDistance like '%" + totalDistance + "%'" : "") + (routeDayOfTheWeek != null ? " and RouteDayOfTheWeek like '%" + routeDayOfTheWeek + "%'" : "") + (active != null ? " and Active = " + (active == true ? "1" : "0") : "") ) ; results = R_PlannedRoute.Query(sql); return(results); }