예제 #1
0
        public async Task UpdateAsync(Vehicle vehicle)
        {
            var vehicleToUpdate = await GetVehicleEntityAsync(vehicle.Id);

            if (vehicleToUpdate == null)
                throw new RecordNotFoundException("This vehicle does not exist.");

            vehicleToUpdate.Mileage = vehicle.Mileage;
            vehicleToUpdate.Speed = vehicle.Speed;
            vehicleToUpdate.Type = (int)vehicle.VehicleType;
        }
예제 #2
0
        public async Task<int> AddAsync(Vehicle vehicle)
        {
            var newVehicle = new Entities.Vehicle
            {
                Mileage = vehicle.Mileage,
                Speed = vehicle.Speed,
                CreatedDttm = DateTime.Now,
                Type = (int)vehicle.VehicleType
            };

            context.Add(newVehicle);
            await context.SaveChangesAsync();
            return newVehicle.Id;
        }