An optimization method for efficiently managing the energy consumption of aggregated demand side resources (DSRs) in a Microgrid (MG) is proposed. A comprehensive physical model for an office building is constructed, taking into account the thermal dynamics due to the building’s envelope, and the flexible loads, such as the heating, ventilation, and air conditioning (HVAC) system and the electric vehicle (EV). The HVAC is controlled to enable the building participate in a demand response program while keep the customers’ comfort levels at a certain range. The EV is modelled as another demand side resource which can also be dispatched in a demand response program when they are parked in the office buildings. Finally, the simulation findings illustrate the effectiveness of the suggested approach in efficiently managing energy consumption across office buildings and EVs, resulting in cost savings for the DSRs.