/// <summary> /// Save the specified location. /// </summary> /// <param name="location">The location to be saved.</param> /// <returns>Number of affected rows.</returns> public static int Save(Location location) { using (SqlConnection connection = SamenSterkerDB.GetConnection()) { int rowsAffected = connection.Execute( sql: isNew(location) ? insertCommand : updateCommand, param: location ); //SetIdentity<int>(connection, id => subCategory.Id = id); return rowsAffected; } }
/// <summary> /// Delete the specified location. /// </summary> /// <param name="location">The location to be deleted.</param> /// <returns>Number of affected rows.</returns> public static int Delete(Location location) { const string deleteCommand = "DELETE FROM Location WHERE Id = @LocationId"; using (SqlConnection connection = SamenSterkerDB.GetConnection()) { return connection.Execute( sql: deleteCommand, param: location ); } }
private static Reservation ReservationMapper( Reservation reservation, Location location, Company company) { reservation.Location = location; reservation.Company = company; return reservation; }
private static bool isNew(Location location) { return location.Id == 0; }