Пример #1
0
        public object Post(Meter request)
        {
            // Retrieve PK.
            var unitNumber = request.UnitNumber;

            // Retrieve obj from IMDB based on PK.
            var imdb = (InMemoryDB) Session[unitNumber];
            if (imdb == null)
            {
                imdb = new InMemoryDB();
            }

            if (request.MeterReading > 0)
            {
                imdb.CurrentMeterReading = request.MeterReading;
            }
            if (request.FuelPurchaseAmount > 0)
            {
                imdb.TotalFuelPurchaseAmount += request.FuelPurchaseAmount;
            }

            // Save obj to IMDB.
            Session[unitNumber] = imdb;

            // Return repsonse obj.
            return new MeterResponse {Id = 1};
        }
Пример #2
0
        public object Post(Meter request)
        {
            // Retrieve PK.
            var unitNumber = request.UnitNumber;

            // Retrieve obj from IMDB based on PK.
            var imdb = (InMemoryDB)Session[unitNumber];

            if (imdb == null)
            {
                imdb = new InMemoryDB();
            }

            if (request.MeterReading > 0)
            {
                imdb.CurrentMeterReading = request.MeterReading;
            }
            if (request.FuelPurchaseAmount > 0)
            {
                imdb.TotalFuelPurchaseAmount += request.FuelPurchaseAmount;
            }

            // Save obj to IMDB.
            Session[unitNumber] = imdb;

            // Return repsonse obj.
            return(new MeterResponse {
                Id = 1
            });
        }
        public object Any(MeterQuery request)
        {
            // Retrieve PK.
            var unitNumber = request.UnitNumber;

            // Retrieve obj from IMDB based on PK.
            var imdb = (InMemoryDB) Session[unitNumber];
            if (imdb == null)
            {
                imdb = new InMemoryDB();
            }

            if (unitNumber == "100")
            {
                throw new NotImplementedException("This is a test");
            }

            // Return repsonse obj.
            return new MeterQueryResponse {
                TotalFuelPurchaseAmount = imdb.TotalFuelPurchaseAmount,
                CurrentMeterReading = imdb.CurrentMeterReading
            };
        }
Пример #4
0
        public object Any(MeterQuery request)
        {
            // Retrieve PK.
            var unitNumber = request.UnitNumber;

            // Retrieve obj from IMDB based on PK.
            var imdb = (InMemoryDB)Session[unitNumber];

            if (imdb == null)
            {
                imdb = new InMemoryDB();
            }

            if (unitNumber == "100")
            {
                throw new NotImplementedException("This is a test");
            }

            // Return repsonse obj.
            return(new MeterQueryResponse {
                TotalFuelPurchaseAmount = imdb.TotalFuelPurchaseAmount,
                CurrentMeterReading = imdb.CurrentMeterReading
            });
        }