Uplink and Downlink Resource Allocation in D2D-Enabled Heterogeneous Networks