public IEnumerable <ItemShort> Search(ItemSearchParameters parameters) { List <ItemShort> itemInfo = new List <ItemShort>(); using (var cn = new SqlConnection(Settings.GetConnectionString())) { var param = new DynamicParameters(); param.Add("@MinValue", parameters.MinValue); param.Add("@MaxValue", parameters.MaxValue); param.Add("@ItemName", parameters.ItemName); param.Add("@CategoryName", parameters.CategoryName); return(cn.Query <ItemShort>("ItemSelectForSearch", parameters, commandType: CommandType.StoredProcedure)); //string query = "SELECT I.DateAdded,[Description],DisplayValue,Favorite,Featured,ItemName,ItemPictureURL,RealValue, Ca.CategoryName, " + // "A.ArticleId FROM Item I inner join ItemCategory ICa on I.ItemId = ICa.ItemId inner join ItemArticle IA on I.ItemId = IA.ItemId " + // "inner join Category Ca on ICa.CategoryId = CA.CategoryId inner join Article A on IA.ArticleId = A.ArticleId WHERE 1 = 1 "; //SqlCommand cmd = new SqlCommand(); //cmd.Connection = cn; //if (parameters.MinValue.HasValue) //{ // query += "AND DisplayValue >= @MinValue "; // cmd.Parameters.AddWithValue("@MinValue", parameters.MinValue.Value); //} //if (parameters.MaxValue.HasValue) //{ // query += "AND DisplayValue >= @MaxValue "; // cmd.Parameters.AddWithValue("@MaxValue", parameters.MaxValue.Value); //} //if (!string.IsNullOrEmpty(parameters.ItemName)) //{ // query += "AND ItemName LIKE @ItemName "; // cmd.Parameters.AddWithValue("@ItemName", '%' + parameters.ItemName + '%'); //} //if (!string.IsNullOrEmpty(parameters.CategoryName)) //{ // query += "AND CategoryName LIKE @CategoryName "; // cmd.Parameters.AddWithValue("@CategoryName", '%' + parameters.CategoryName + '%'); //} //cmd.CommandText = query; //cn.Open(); } //return itemInfo; }
public IHttpActionResult Search(decimal?minValue, decimal?maxValue, string itemName, string categoryName) { var repo = new PirateItemRepository(); try { var parameters = new ItemSearchParameters() { MinValue = minValue, MaxValue = maxValue, ItemName = itemName, CategoryName = categoryName }; var result = repo.Search(parameters); return(Ok(result)); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
/// <summary> /// Finds the catalog items table. /// </summary> /// <param name="parameters">The parameters.</param> /// <param name="responseGroup">The response group.</param> /// <returns></returns> public DataTable FindCatalogItemsTable(ItemSearchParameters parameters, CatalogNodeResponseGroup responseGroup) { return(CatalogNodeManager.GetCatalogItemsTable(parameters, responseGroup)); }
/// <summary> /// Finds the catalog items table. /// </summary> /// <param name="parameters">The parameters.</param> /// <param name="responseGroup">The response group.</param> /// <returns></returns> public DataTable FindCatalogItemsTable(ItemSearchParameters parameters, CatalogNodeResponseGroup responseGroup) { return(_Proxy.FindCatalogItemsTable(parameters, responseGroup)); }
/// <summary> /// Finds the catalog items table. /// </summary> /// <param name="parameters">The parameters.</param> /// <returns></returns> public DataTable FindCatalogItemsTable(ItemSearchParameters parameters) { return(_Proxy.FindCatalogItemsTable(parameters)); }