//* * * INVOICE MANAGER METHODS
        /// GET METHODS
        /// <summary>
        /// Retrieves all invoices on meter with specified id.
        /// </summary>
        /// <param name="meterId"></param>
        /// <returns>JSON representation of List[Invoice], wrapped in EMResponse obejct</returns>
        public string getInvoicesForMeter(int meterId)
        {
            EMResponse response = new EMResponse();
            try
            {
                invoiceMgr = new InvoiceManager();
                response.data = EMConverter.fromObjectToJSON(invoiceMgr.getInvoicesForMeter(meterId));
                response.status = ok;
            }
            catch (Exception e)
            {
                response.status = error;
                response.data = e.Message;
            }

            return EMConverter.fromObjectToJSON(response);
        }
        ///EDIT METHODS
        /// <summary>
        /// Updates an invoice with the specifed id with the details of the provided invoice object and updates the
        /// annual cost of the relvant Property object.
        /// </summary>
        /// <param name="invoiceId">id of invoice to update</param>
        /// <param name="invoiceJSON">JSON representation of the updated invoice</param>
        /// <param name="propertyId">id of the property to which the invoice belongs.  Required to update the annual cost at the property.</param>
        /// <returns>JSON representation of updated Invoice object, wrapped in EMResponse object.</returns>
        public string editInvoice(int invoiceId, string invoiceJSON, int propertyId)
        {
            EMResponse response = new EMResponse();
            try
            {
                invoiceMgr = new InvoiceManager();
                invoiceMgr.editInvoice(invoiceId, invoiceJSON, propertyId);
                response.status = ok;
            }
            catch (Exception e)
            {
                response.status = error;
                response.data = e.Message;
            }

            return EMConverter.fromObjectToJSON(response);
        }
示例#3
0
        //-->INVOICE MAAGER

        public Invoice getLastInvoice(int meterId)
        {
            invoiceMgr = new InvoiceManager();
            return(invoiceMgr.getLastInvoice(meterId));
        }
        ///CREATE METHODS
        /// <summary>
        /// Creates an invoice with the specified parameters and updates the annual cost of the relvant Property object.
        /// </summary>
        /// <param name="meterId">id of the meter to which the invoice belongs</param>
        /// <param name="billDate">the date of the invoice</param>
        /// <param name="startDate">the start date of the consumption being invoiced</param>
        /// <param name="endDate">the end date of the consumption being invoiced</param>
        /// <param name="kWh">the kWh on the invoice</param>
        /// <param name="consumptionCharge">the cost of the energy ONLY (in £)</param>
        /// <param name="standingCharge">the cost of the standing charge ONLY (in £)</param>
        /// <param name="otherCharge">total of all other costs (not used to validate the invoice) (in £)</param>
        /// <param name="propertyId">the id of the property to which the invoice belongs</param>
        /// <returns>JSON representation of the id of the created invoice - int, wrapped in EMResponse object</returns>
        public string createInvoice(int meterId, string billDate, string startDate, string endDate, int kWh,
            double consumptionCharge, double standingCharge, double otherCharge, int propertyId)
        {
            EMResponse response = new EMResponse();
            try
            {
                invoiceMgr = new InvoiceManager();
                response.data = EMConverter.fromObjectToJSON(invoiceMgr.createInvoice(meterId, billDate, startDate, endDate,
                                                                                        kWh, consumptionCharge,
                                                                                        standingCharge, otherCharge, propertyId));
                response.status = ok;
            }
            catch (Exception e)
            {
                response.status = error;
                response.data = e.Message;
            }

            return EMConverter.fromObjectToJSON(response);
        }
 //-->INVOICE MAAGER
 public Invoice getLastInvoice(int meterId)
 {
     invoiceMgr = new InvoiceManager();
     return invoiceMgr.getLastInvoice(meterId);
 }