public static void AddVenue(Venue venue, out int? venueId, out DateTime createdDate) { using (SqlConnection conn = Helper.GetConnection()) { using (SqlCommand cmd = new SqlCommand(Constants.StoredProcedures.VenueManager.AddVenue, conn)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@Name", venue.Name); if (!string.IsNullOrEmpty(venue.Name)) cmd.Parameters.AddWithValue("@Profile", venue.Profile); if (!string.IsNullOrEmpty(venue.PostalCode)) cmd.Parameters.AddWithValue("@PostalCode", venue.PostalCode); if (venue.PriceAverage.HasValue) cmd.Parameters.AddWithValue("@PriceAverage", venue.PriceAverage.Value); SqlParameter prmVenueId = new SqlParameter(); prmVenueId.Direction = ParameterDirection.Output; prmVenueId.DbType = DbType.Int32; prmVenueId.ParameterName = "@VenueID"; cmd.Parameters.Add(prmVenueId); SqlParameter prmCreatedDate = new SqlParameter(); prmCreatedDate.Direction = ParameterDirection.Output; prmCreatedDate.DbType = DbType.DateTime; prmCreatedDate.ParameterName = "@CreatedDate"; cmd.Parameters.Add(prmCreatedDate); conn.Open(); cmd.ExecuteScalar(); venueId = (int)cmd.Parameters["@VenueID"].Value; createdDate = (DateTime)cmd.Parameters["@CreatedDate"].Value; } } }
private void LoadViewVenue() { if (ItemID.HasValue) { ViewVenue = VenueManager.GetVenue(ItemID.Value); } }
public static void UpdateVenue(Venue venue) { using (SqlConnection conn = Helper.GetConnection()) { using (SqlCommand cmd = new SqlCommand(Constants.StoredProcedures.VenueManager.UpdateVenue, conn)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@VenueID", venue.ID); cmd.Parameters.AddWithValue("@Name", venue.Name); if (!string.IsNullOrEmpty(venue.Profile)) cmd.Parameters.AddWithValue("@Profile", venue.Profile); if (!string.IsNullOrEmpty(venue.PostalCode)) cmd.Parameters.AddWithValue("@PostalCode", venue.PostalCode); if (venue.PriceAverage.HasValue) cmd.Parameters.AddWithValue("@PriceAverage", venue.PriceAverage.Value); conn.Open(); cmd.ExecuteNonQuery(); } } }
public static void RemoveVenue(Venue venue) { if (venue.ID.HasValue) RemoveVenue(venue.ID.Value); else throw new Exception("Venue has not been saved and thus cannot be removed."); }