/** * Gets all Reservations at a Performance, separated by SeatType * Maps each reservation's Price * Regroups and returns all Reservations at a Performance into an IEnumerable<Reservation> */ public void SetNewReservationPrices(int performanceId, ReservationPrices prices) { var budget = new UpdatePricesObject { PerformanceId = performanceId, Type = SeatType.Budget, Price = prices.Budget }; var moderate = new UpdatePricesObject { PerformanceId = performanceId, Type = SeatType.Moderate, Price = prices.Moderate }; var premier = new UpdatePricesObject { PerformanceId = performanceId, Type = SeatType.Premier, Price = prices.Premier }; _reservationRepository.ChangeReservationPrices(budget); _reservationRepository.ChangeReservationPrices(moderate); _reservationRepository.ChangeReservationPrices(premier); }
public void ChangeReservationPrices(UpdatePricesObject update) { using (SqlConnection sourceConnection = new SqlConnection(connectionString)) { sourceConnection.Open(); try { var priceParam = new SqlParameter("@price", update.Price); var seatTypeParam = new SqlParameter("@seatType", update.Type); var performanceIdParam = new SqlParameter("@performanceId", update.PerformanceId); Context.Database.ExecuteSqlCommand("dbo.BulkUpdatePrices @price, @seatType, @performanceId", priceParam, seatTypeParam, performanceIdParam); Console.WriteLine("Reservation prices updated successfully."); } catch (Exception e) { Console.WriteLine(e.Message); } finally { sourceConnection.Close(); } } }