public void add(BookingsData data) { SqlConnection MyC = new SqlConnection(); MyC.ConnectionString = "Data Source=(local)\\SQLEXPRESS;Initial Catalog=BOOKINGS_HOTELS;Integrated Security = true"; MyC.Open(); SqlCommand MyCom = new SqlCommand("CMD_ADD", MyC); MyCom.CommandType = CommandType.StoredProcedure; MyCom.Parameters.Add("@city", SqlDbType.Text); MyCom.Parameters["@city"].Value = data.city; MyCom.Parameters.Add("@name", SqlDbType.Text); MyCom.Parameters["@name"].Value = data.name; MyCom.Parameters.Add("@rating", SqlDbType.Text); MyCom.Parameters["@rating"].Value = data.rating; MyCom.Parameters.Add("@rib", SqlDbType.Text); MyCom.Parameters["@rib"].Value = data.rib; MyCom.Parameters.Add("@email", SqlDbType.Text); MyCom.Parameters["@email"].Value = data.email; MyCom.Parameters.Add("@first_name", SqlDbType.Text); MyCom.Parameters["@first_name"].Value = data.first_name; MyCom.Parameters.Add("@last_name", SqlDbType.Text); MyCom.Parameters["@last_name"].Value = data.last_name; //int Res = Convert.ToInt32(MyCom.ExecuteScalar()); MyCom.ExecuteScalar(); MyCom.Dispose(); MyC.Close(); //return Res; }
static void Main(string[] args) { if (args[0] == "" || args[0] == "?") { Console.Out.WriteLine("help:"); Console.Out.WriteLine("takes two arguments, converting from json to comma separated file:"); Console.Out.WriteLine("input file (the json format)"); Console.Out.WriteLine("output file (the result generated as csv)"); } BookingsData data = LoadJson(args[0]); data.ExportData(args[1]); }
public bool book(BookingsData data) { bool addSuccess = false; Flights flights = new Flights(); Hotels hotels = new Hotels(); using (TransactionScope transaction = new TransactionScope()) { try { flights.add(data); hotels.add(data); addSuccess = true; transaction.Complete(); } catch (Exception e) { Console.WriteLine("Error when BookingManager.book " + e); //throw e; } } return(addSuccess); }
// POST api/trips public void Post([FromBody] BookingsData data) { Console.WriteLine(data); Bookings.BookingsManager b = new Bookings.BookingsManager(); b.Reserve(data); }