public ActionResult FinalizeReservation(string dateStart, string dateEnd, string totalPrice, string[] selectedRooms) { /* * 1) add dateStart, dateEnd, totalPrice and idClient in table Reservation * 2) retrieve last idReservation and save it * 3) loop through listOfRooms and each time call BLL.UpdateRoomReservation to insert idRoom and IdReservation * */ int[] arrayIdRooms = new int[selectedRooms.Length]; //extract all idrooms selected and put them in an array for (int i = 0; i < selectedRooms.Length; i++) { arrayIdRooms[i] = Convert.ToInt32(selectedRooms[i].ToString()); } Client client = (Client)Session["IdClient"]; //convert strings to appropriate formats DateTime dateStartUsable = Convert.ToDateTime(dateStart.ToString()); DateTime dateEndUsable = Convert.ToDateTime(dateEnd.ToString()); decimal totalPriceUsable = Convert.ToDecimal(totalPrice.ToString()); //step 1 ReservationManager.AddNewReservation(client.Idclient, dateStartUsable, dateEndUsable, totalPriceUsable); //step 2 int idReservation = ReservationManager.GetLastIdReservation(); //step 3 for (int i = 0; i < arrayIdRooms.Length; i++) { ReservationManager.AddNewRoomReservation(arrayIdRooms[i], idReservation); } return(View("Final")); }