Ejemplo n.º 1
0
        /// <summary>
        /// Finds the matching Notebooks
        /// </summary>
        /// <param name="notebookSearchData">the query params</param>
        /// <param name="db">the database</param>
        /// <returns></returns>
        public static List <Product> FindMatchingNotebooks(NotebookQueryParams notebookSearchData, IDatabase db)
        {
            List <IQueryPart> queryParts = GetQueryPartsNotebook(notebookSearchData);
            string            querieText;

            if (queryParts.Count == 0)
            {
                querieText = "SELECT product_id FROM Notebooks ";
            }
            else
            {
                querieText = QueryCreation.CreateQueryText(queryParts);
            }

            string CommandGetNotebooks = string.Format("SELECT * FROM " +
                                                       "  ( {0} ) AS PID " +
                                                       " INNER JOIN Products As p ON p.product_id = PID.product_id", querieText);

            using (var getNotebook = db.CreateQueryCommand(CommandGetNotebooks))
            {
                QueryCreation.SetQueryParameters(getNotebook, queryParts);
                IReader reader = getNotebook.ExecuteReader();
                return(ProductReader.ReadForProducts(reader));
            }
        }
Ejemplo n.º 2
0
        private static List <IQueryPart> GetQueryPartsNotebook(NotebookQueryParams param)
        {
            var queryParts = new List <IQueryPart>();

            FillQueryPartsWithGraphicQueries(queryParts, param);
            FillQueryPartsWithCPUQueries(queryParts, param);
            FillQueryPartsWithHardDriveQueries(queryParts, param);
            FillQueryPartsWithNotebookQuery(queryParts, param);
            FillQueryPartsWithNotebookProductQuery(queryParts, param);
            return(queryParts);
        }
Ejemplo n.º 3
0
 private static void FillQueryPartsWithCPUQueries(List <IQueryPart> queryParts, NotebookQueryParams param)
 {
     if (param.CPUQueryParams == null)
     {
         return;
     }
     if (param.CPUQueryParams.cpuCount != null)
     {
         queryParts.Add(GetNotebooksByCpuCountQuery(param.CPUQueryParams.cpuCount.Value));
     }
     if (param.CPUQueryParams.cpuName != null)
     {
         queryParts.Add(GetNotebooksByCPUNameQuery(param.CPUQueryParams.cpuName));
     }
     if (param.CPUQueryParams.cpuClockRate != null)
     {
         queryParts.Add(GetNotebooksByCPUClockRateQuery(param.CPUQueryParams.cpuClockRate.Value));
     }
 }
Ejemplo n.º 4
0
 private static void FillQueryPartsWithHardDriveQueries(List <IQueryPart> queryParts, NotebookQueryParams param)
 {
     if (param.HardDriveQueryParams == null)
     {
         return;
     }
     if (param.HardDriveQueryParams.hdMemoryRange != null)
     {
         queryParts.Add(GetNotebooksByhardDriveMemory(param.HardDriveQueryParams.hdMemoryRange.Value));
     }
     if (param.HardDriveQueryParams.hdType != null)
     {
         queryParts.Add(GetNotebooksByhardDriveType(param.HardDriveQueryParams.hdType));
     }
 }
Ejemplo n.º 5
0
 private static void FillQueryPartsWithGraphicQueries(List <IQueryPart> queryParts, NotebookQueryParams param)
 {
     if (param.GraphicQueryParams == null)
     {
         return;
     }
     if (param.GraphicQueryParams.graphicCardName != null)
     {
         queryParts.Add(GetNotebooksByGraphicCardName(param.GraphicQueryParams.graphicCardName));
     }
     if (param.GraphicQueryParams.vramRange != null)
     {
         queryParts.Add(GetNotebooksByVRAMMemory(param.GraphicQueryParams.vramRange.Value));
     }
 }
Ejemplo n.º 6
0
 private static void FillQueryPartsWithNotebookQuery(List <IQueryPart> queryParts, NotebookQueryParams param)
 {
     if (param.NotebookDataQueryParams == null)
     {
         return;
     }
     if (param.NotebookDataQueryParams.notebookName != null)
     {
         queryParts.Add(GetNotebooksByName(param.NotebookDataQueryParams.notebookName));
     }
     if (param.NotebookDataQueryParams.priceRange != null)
     {
         queryParts.Add(GetNotebooksByPriceQuery(param.NotebookDataQueryParams.priceRange));
     }
     if (param.NotebookDataQueryParams.os != OS.empty)
     {
         queryParts.Add(GetNotebooksByOsQuery(param.NotebookDataQueryParams.os));
     }
     if (param.NotebookDataQueryParams.batteryTimeRange != null)
     {
         queryParts.Add(GetNotebooksByBatteryTimeQuery(param.NotebookDataQueryParams.batteryTimeRange.Value));
     }
     if (param.NotebookDataQueryParams.ramMemoryRange != null)
     {
         queryParts.Add(GetNotebooksByRAMQuery(param.NotebookDataQueryParams.ramMemoryRange.Value));
     }
 }
Ejemplo n.º 7
0
 public List <Notebook> FindMatchingNotebook(NotebookQueryParams notebookParams)
 {
     return(GetNotebooks(NotebookSearchQueries.FindMatchingNotebooks(notebookParams, _db)));
 }