/// <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 <AvailBidResponseAvailBidsBid> FetchDataBids(string agency, string category, string location, string title) { try { List <AvailBidResponseAvailBidsBid> list = new List <AvailBidResponseAvailBidsBid>(); string sql = "SELECT BidID, ItemID, Title, Category, Agency, Location, DatePosted, DateOpened, PreBidDate, SpecificationsDate FROM Bid {0} ORDER BY Title"; 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 AvailBidResponseAvailBidsBid bid = new AvailBidResponseAvailBidsBid(); bid.ID = reader["BidID"].ToString(); bid.ItemID = reader["ItemID"].ToString(); bid.Agency = (string)reader["Agency"]; bid.Title = (string)reader["Title"]; bid.Category = (string)reader["Category"]; bid.Location = (string)reader["Location"]; bid.DateOpened = reader["DateOpened"] is DBNull ? "" : reader["DateOpened"].ToString(); bid.DatePosted = reader["DatePosted"] is DBNull ? "" : reader["DatePosted"].ToString(); bid.PreBidDate = reader["PreBidDate"] is DBNull ? "" : reader["PreBidDate"].ToString(); bid.SpecificationsDate = reader["SpecificationsDate"] is DBNull ? "" : reader["SpecificationsDate"].ToString(); list.Add(bid); bid = null; } while (reader.Read()); } } } } return(list); } catch (Exception) { throw; } }
/// <summary> /// Fetches the data in the database for the bids by a set ID. /// </summary> /// <param name="ID">Id of the bid.</param> /// <returns>An Available bid.</returns> public static AvailBidResponseAvailBidsBid FetchDataBidByID(int ID) { try { AvailBidResponseAvailBidsBid bid = new AvailBidResponseAvailBidsBid(); string sql = "SELECT BidID, ItemID, Title, Category, Agency, Location, DatePosted, DateOpened, PreBidDate, SpecificationsDate FROM Bid {0}"; sql = String.Format(sql, "WHERE BidID = " + ID.ToString()); SetConnectionString(); using (var connection = new SqlConnection(_connectionString)) { connection.Open(); using (var command = new SqlCommand(sql, connection)) { using (var reader = command.ExecuteReader()) { if (reader.Read()) { //sets the value from the reader bid.ID = reader["BidID"].ToString(); bid.ItemID = reader["ItemID"].ToString(); bid.Agency = (string)reader["Agency"]; bid.Title = (string)reader["Title"]; bid.Category = (string)reader["Category"]; bid.Location = (string)reader["Location"]; bid.DateOpened = reader["DateOpened"] is DBNull ? "" : reader["DateOpened"].ToString(); bid.DatePosted = reader["DatePosted"] is DBNull ? "" : reader["DatePosted"].ToString(); bid.PreBidDate = reader["PreBidDate"] is DBNull ? "" : reader["PreBidDate"].ToString(); bid.SpecificationsDate = reader["SpecificationsDate"] is DBNull ? "" : reader["SpecificationsDate"].ToString(); } } } } return bid; } catch (Exception) { throw; } }
/// <summary> /// Fetches the data in the database for the bids by a set ID. /// </summary> /// <param name="ID">Id of the bid.</param> /// <returns>An Available bid.</returns> public static AvailBidResponseAvailBidsBid FetchDataBidByID(int ID) { try { AvailBidResponseAvailBidsBid bid = new AvailBidResponseAvailBidsBid(); string sql = "SELECT BidID, ItemID, Title, Category, Agency, Location, DatePosted, DateOpened, PreBidDate, SpecificationsDate FROM Bid {0}"; sql = String.Format(sql, "WHERE BidID = " + ID.ToString()); SetConnectionString(); using (var connection = new SqlConnection(_connectionString)) { connection.Open(); using (var command = new SqlCommand(sql, connection)) { using (var reader = command.ExecuteReader()) { if (reader.Read()) { //sets the value from the reader bid.ID = reader["BidID"].ToString(); bid.ItemID = reader["ItemID"].ToString(); bid.Agency = (string)reader["Agency"]; bid.Title = (string)reader["Title"]; bid.Category = (string)reader["Category"]; bid.Location = (string)reader["Location"]; bid.DateOpened = reader["DateOpened"] is DBNull ? "" : reader["DateOpened"].ToString(); bid.DatePosted = reader["DatePosted"] is DBNull ? "" : reader["DatePosted"].ToString(); bid.PreBidDate = reader["PreBidDate"] is DBNull ? "" : reader["PreBidDate"].ToString(); bid.SpecificationsDate = reader["SpecificationsDate"] is DBNull ? "" : reader["SpecificationsDate"].ToString(); } } } } return(bid); } catch (Exception) { throw; } }
/// <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<AvailBidResponseAvailBidsBid> FetchDataBids(string agency, string category, string location, string title) { try { List<AvailBidResponseAvailBidsBid> list = new List<AvailBidResponseAvailBidsBid>(); string sql = "SELECT BidID, ItemID, Title, Category, Agency, Location, DatePosted, DateOpened, PreBidDate, SpecificationsDate FROM Bid {0} ORDER BY Title"; 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 AvailBidResponseAvailBidsBid bid = new AvailBidResponseAvailBidsBid(); bid.ID = reader["BidID"].ToString(); bid.ItemID = reader["ItemID"].ToString(); bid.Agency = (string)reader["Agency"]; bid.Title = (string)reader["Title"]; bid.Category = (string)reader["Category"]; bid.Location = (string)reader["Location"]; bid.DateOpened = reader["DateOpened"] is DBNull ? "" : reader["DateOpened"].ToString(); bid.DatePosted = reader["DatePosted"] is DBNull ? "" : reader["DatePosted"].ToString(); bid.PreBidDate = reader["PreBidDate"] is DBNull ? "" : reader["PreBidDate"].ToString(); bid.SpecificationsDate = reader["SpecificationsDate"] is DBNull ? "" : reader["SpecificationsDate"].ToString(); list.Add(bid); bid = null; } while (reader.Read()); } } } } return list; } catch (Exception) { throw; } }