public static List <ProductDTO> GetStroymats(StroymatFilter filter) { DataTable dt = new DataTable(); List <ProductDTO> ProductsList = new List <ProductDTO>(); using (SqlConnection conn = new SqlConnection(cs)) { SqlCommand cmd = new SqlCommand("sp_get_stroymats", conn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@stroymat_id", filter.ID); cmd.Parameters.AddWithValue("@min_amount", filter.MinPrice); cmd.Parameters.AddWithValue("@max_amount", filter.MaxPrice); cmd.Parameters.AddWithValue("@type", filter.Stroymat_type.ConvertToSqlArr()); cmd.Parameters.AddWithValue("@country", filter.Countries.ConvertToSqlArr()); cmd.Parameters.AddWithValue("@manufact", filter.Manufacturers.ConvertToSqlArr()); cmd.Parameters.AddWithValue("@start", filter.Start); cmd.Parameters.AddWithValue("@end", filter.End); conn.Open(); dt.Load(cmd.ExecuteReader()); foreach (DataRow dr in dt.Rows) { ProductsList.Add(dr.ConvertToProductDTO()); } return(ProductsList); } }
public JsonResult GetStroymats(StroymatFilter filter) { var els = DataProvider.GetStroymats(filter); return(new JsonResult(els) { }); }