Ejemplo n.º 1
0
        /// <summary>
        /// Retreives list of all heating types in the database
        /// </summary>
        /// <returns>JSON repsentation of List[HeatingType], wrapped in EMResponse object</returns>
        public string getHeatingTypes()
        {
            EMResponse response = new EMResponse();
            try
            {
                propertyMgr = new PropertyManager();
                response.data = EMConverter.fromObjectToJSON(propertyMgr.getHeatingTypes());
                response.status = ok;
            }
            catch (Exception e)
            {
                response.status = error;
                response.data = e.Message;
            }

            return EMConverter.fromObjectToJSON(response);
        }
Ejemplo n.º 2
0
        /// EDIT METHODS
        /// <summary>
        /// Updates the property with the specifed id with the attributes of the newProperty object.  Child objects are not updated.
        /// </summary>
        /// <param name="propertyId">id of property to update</param>
        /// <param name="newProperty">JSON representation of property with updated details</param>
        /// <returns>JSON representation of updated Property, wrapped in EMResponse obejct</returns>
        public string editProperty(int propertyId, string newProperty)
        {
            EMResponse response = new EMResponse();
            try
            {
                propertyMgr = new PropertyManager();
                response.data = EMConverter.fromObjectToJSON(propertyMgr.editProperty(propertyId, newProperty));
                response.status = ok;
            }
            catch (Exception e)
            {
                response.status = error;
                response.data = e.Message;
            }

            return EMConverter.fromObjectToJSON(response);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Retrieves the total of the specified datatype for gas between two dates at a property (ie the total over all gas meters).
        /// </summary>
        /// <param name="propertyId"></param>
        /// <param name="startDate">shortdate string</param>
        /// <param name="endDate">shortdate string</param>
        /// <param name="dataTypeId">(int)DataType</param>
        /// <returns>JSON representation of a double, wrapped in EMResponse obejct</returns>
        public string getGasData(int propertyId, string startDate, string endDate, int dataTypeId)
        {
            EMResponse response = new EMResponse();
            try
            {
                propertyMgr = new PropertyManager();

                response.data = EMConverter.fromObjectToJSON(propertyMgr.getGasData(propertyId, startDate, endDate, dataTypeId));
                response.status = ok;
            }
            catch (Exception e)
            {
                response.status = error;
                response.data = e.Message;
            }

            return EMConverter.fromObjectToJSON(response);
        }
Ejemplo n.º 4
0
        ///CREATE METHODS
        /// <summary>
        /// Creates a property with the specified parameters
        /// </summary>
        /// <param name="name">Title of the property</param>
        /// <param name="postcode">Postcode</param>
        /// <param name="floorArea">in m2, if left at zero the area of the benchmark property will be used</param>
        /// <param name="numbBedrooms"></param>
        /// <param name="typeId">can be determined using emAPI.getPropertyTypeId(int heatingId, int buildingId, int wallId)</param>
        /// <param name="userId">userId to which the property belongs</param>
        /// <returns>JSON representation of property id - int, wrapped in EMResponse obejct</returns>
        public string createProperty(string name, string postcode, int floorArea, int numbBedrooms, int typeId, int userId)
        {
            EMResponse response = new EMResponse();
            try
            {
                propertyMgr = new PropertyManager();

                response.data = EMConverter.fromObjectToJSON(propertyMgr.createProperty(name, postcode, floorArea, numbBedrooms, typeId, userId));
                response.status = ok;
            }
            catch (Exception e)
            {
                response.status = error;
                response.data = e.Message;
            }

            return EMConverter.fromObjectToJSON(response);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Retreieves the id of the property type with matching walls, heating and building types.
        /// </summary>
        /// <param name="heatingId"></param>
        /// <param name="buildingId"></param>
        /// <param name="wallId"></param>
        /// <returns>Id of the matching property type - int wrapped in EMRepsonse object</returns>
        public string getPropertyTypeId(int heatingId, int buildingId, int wallId)
        {
            EMResponse response = new EMResponse();
            try
            {
                propertyMgr = new PropertyManager();
                response.data = EMConverter.fromObjectToJSON(propertyMgr.getPropertyTypeId(heatingId, buildingId, wallId));
                response.status = ok;
            }
            catch (Exception e)
            {
                response.status = error;
                response.data = e.Message;
            }

            return EMConverter.fromObjectToJSON(response);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Retrieves the most recent date of the specified datatype at the property (ie over all meters)
        /// </summary>
        /// <param name="propertyId"></param>
        /// <param name="dataTypeId"></param>
        /// <returns>JSON representaion of date as string, wrapped in EMResponse obejct</returns>
        public string getMostRecentDate(int propertyId, int dataTypeId)
        {
            EMResponse response = new EMResponse();
            try
            {
                propertyMgr = new PropertyManager();
                response.data = EMConverter.fromObjectToJSON(propertyMgr.getMostRecentDate(propertyId, (DataType)dataTypeId));
                response.status = ok;
            }
            catch (Exception e)
            {
                response.status = error;
                response.data = e.Message;
            }

            return EMConverter.fromObjectToJSON(response);
        }
 //--> PROPERTY MANAGER
 public void updatePropertyAnnualTotalkWh(int propertyId)
 {
     propertyMgr = new PropertyManager();
     propertyMgr.updateAnnualTotalkWh(propertyId);
 }
 public void updateAnnualCO2(int propertyId)
 {
     propertyMgr = new PropertyManager();
     propertyMgr.updateAnnualCO2(propertyId);
 }