public void BrokedRoom(BrokedRoomDTO room) { try { string connectionString = ConfigurationManager.ConnectionStrings["ConnectToSQL"].ConnectionString; IRoomRepository repository = new RoomRepository(connectionString); NewRoom newRoom = new NewRoom(); newRoom.Fio = room.Fio; newRoom.NumberPhone = room.NumberPhone; newRoom.Email = room.Email; newRoom.DescriptionRommId = room.DescriptionRommId; newRoom.DateFrom = room.DateFrom; newRoom.DateTo = room.DateTo; newRoom.Reserve = room.Reserve; repository.BrokedRoom(newRoom); } catch (Exception e) { Exception baseException = e.GetBaseException(); throw new FaultException(e.Message); } }
public NewRoom AddRecord(NewRoom newRoom) { using (SqlConnection connection = new SqlConnection(this._connectionString)) { connection.Open(); using (SqlCommand command = new SqlCommand(queryInsert, connection)) { command.Parameters.AddWithValue("Fio", newRoom.Fio); command.Parameters.AddWithValue("NumberPhone", newRoom.NumberPhone); command.Parameters.AddWithValue("Email", newRoom.Email); command.Parameters.AddWithValue("DescriptionRommId", newRoom.DescriptionRommId); command.Parameters.AddWithValue("DateFrom", Convert.ToDateTime(newRoom.DateFrom)); command.Parameters.AddWithValue("DateTo", Convert.ToDateTime(newRoom.DateTo)); command.Parameters.AddWithValue("Reserve", newRoom.Reserve); int connectId = (int)command.ExecuteScalar(); newRoom.Id = connectId; return newRoom; } } }
public void BrokedRoom(NewRoom newRoom) { using (var connection = new SqlConnection(this._connectionString)) { connection.Open(); using (var command = new SqlCommand()) { command.Connection = connection; command.CommandText = "procBrokedRoom"; command.CommandType = System.Data.CommandType.StoredProcedure; command.Parameters.AddWithValue("@Fio", newRoom.Fio); command.Parameters.AddWithValue("@NumberPhone", newRoom.NumberPhone); command.Parameters.AddWithValue("@Email", newRoom.Email); command.Parameters.AddWithValue("@DescriptionRoomId", newRoom.DescriptionRommId); command.Parameters.AddWithValue("@DateFrom", Convert.ToDateTime(newRoom.DateFrom)); command.Parameters.AddWithValue("@DateTo", Convert.ToDateTime(newRoom.DateTo)); command.Parameters.AddWithValue("@Reserve", newRoom.Reserve); command.ExecuteNonQuery(); } } }