示例#1
0
        public async Task UpdateFueling(Fueling oldFueling, Fueling newFueling)
        {
            var rec = new GasRecord {
                Id      = oldFueling.Id,
                Date    = newFueling.Date,
                Vendor  = newFueling.Vendor.Name,
                State   = newFueling.State,
                Gallons = newFueling.Gallons,
                Price   = newFueling.Price,
                Total   = newFueling.Total
            };

            var fields = new List <string>();

            fields.Add(GasRecord.DATE);
            fields.Add(GasRecord.VENDOR);
            fields.Add(GasRecord.STATE);
            if (newFueling.Gallons != oldFueling.Gallons)
            {
                fields.Add(GasRecord.GALLONS);
            }
            if (newFueling.Price != oldFueling.Price)
            {
                fields.Add(GasRecord.PRICE);
            }
            if (newFueling.Total != oldFueling.Total)
            {
                fields.Add(GasRecord.TOTAL);
            }

            rec = await GasTable.UpdateRecord(rec, fields.ToArray());
        }
示例#2
0
        public async Task AddFueling(Fueling fueling)
        {
            var rec = new GasRecord {
                Date    = fueling.Date,
                Vendor  = fueling.Vendor.Name,
                State   = fueling.State,
                Gallons = fueling.Gallons,
                Price   = fueling.Price,
                Total   = fueling.Total
            };

            var fields = new List <string>();

            fields.Add(GasRecord.DATE);
            fields.Add(GasRecord.VENDOR);
            fields.Add(GasRecord.STATE);
            if (rec.Gallons > 0)
            {
                fields.Add(GasRecord.GALLONS);
            }
            if (rec.Price > 0)
            {
                fields.Add(GasRecord.PRICE);
            }
            if (rec.Total > 0)
            {
                fields.Add(GasRecord.TOTAL);
            }

            rec = await GasTable.CreateRecord(rec, fields.ToArray());

            fueling.Id = rec.Id;
        }