Ejemplo n.º 1
0
        /// <summary>
        /// Fetches the data in the database for the bids based on the data for filters entered.
        /// </summary>
        /// <param name="agency">Agency for the bid.</param>
        /// <param name="category">Category of te bid.</param>
        /// <param name="location">Location fro the bid.</param>
        /// <param name="title">Title of the bid.</param>
        /// <returns>List with the available bids.</returns>
        public static List <AvailBidIdResponseAvailBidIdsBid> FetchDataBidIds(string agency, string category, string location, string title)
        {
            try
            {
                List <AvailBidIdResponseAvailBidIdsBid> list = new List <AvailBidIdResponseAvailBidIdsBid>();
                string sql = "SELECT ItemID FROM Bid {0}";

                sql = String.Format(sql, BuildBidsWhere(agency, category, location, title));

                SetConnectionString();
                using (var connection = new SqlConnection(_connectionString))
                {
                    connection.Open();

                    using (var command = new SqlCommand(sql, connection))
                    {
                        using (var reader = command.ExecuteReader())
                        {
                            if (reader.Read())
                            {
                                do
                                {
                                    //sets the value from the reader
                                    AvailBidIdResponseAvailBidIdsBid bid = new AvailBidIdResponseAvailBidIdsBid();
                                    bid.ItemID = reader["ItemID"].ToString();
                                    list.Add(bid);
                                    bid = null;
                                } while (reader.Read());
                            }
                        }
                    }
                }

                return(list);
            }
            catch (Exception)
            {
                throw;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Fetches the data in the database for the bids based on the data for filters entered.
        /// </summary>
        /// <param name="agency">Agency for the bid.</param>
        /// <param name="category">Category of te bid.</param>
        /// <param name="location">Location fro the bid.</param>
        /// <param name="title">Title of the bid.</param>
        /// <returns>List with the available bids.</returns>
        public static List<AvailBidIdResponseAvailBidIdsBid> FetchDataBidIds(string agency, string category, string location, string title)
        {
            try
            {
                List<AvailBidIdResponseAvailBidIdsBid> list = new List<AvailBidIdResponseAvailBidIdsBid>();
                string sql = "SELECT ItemID FROM Bid {0}";

                sql = String.Format(sql, BuildBidsWhere(agency, category, location, title));

                SetConnectionString();
                using (var connection = new SqlConnection(_connectionString))
                {
                    connection.Open();

                    using (var command = new SqlCommand(sql, connection))
                    {
                        using (var reader = command.ExecuteReader())
                        {
                            if (reader.Read())
                            {
                                do
                                {
                                    //sets the value from the reader
                                    AvailBidIdResponseAvailBidIdsBid bid = new AvailBidIdResponseAvailBidIdsBid();
                                    bid.ItemID = reader["ItemID"].ToString();
                                    list.Add(bid);
                                    bid = null;
                                } while (reader.Read());
                            }
                        }
                    }
                }

                return list;
            }
            catch (Exception)
            {
                throw;
            }
        }