public async Task <VehicleMake> DeleteMakeAsync(int id)
        {
            var deleteMake = context.VehicleMakes.Find(id);

            context.Remove(deleteMake);
            await context.SaveChangesAsync();

            return(deleteMake);
        }
Exemple #2
0
        public async Task <T> DeleteAsync(int id)
        {
            var deleteItem = await context.Set <T>().FindAsync(id);

            context.Remove(deleteItem);
            await context.SaveChangesAsync();

            return(deleteItem);
        }
        public void DeleteVehicleById(int id)
        {
            var vehicle = new VehicleDb()
            {
                Id = id
            };

            _context.Remove(vehicle);

            try
            {
                _context.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                return;
            }
        }
            public async Task <Unit> Handle(Command request, CancellationToken cancellationToken)
            {
                var garage = await _context.Garages.FindAsync(request.GarageId);

                if (garage == null)
                {
                    throw new Microsoft.Rest.RestException("Could not find");
                }

                _context.Remove(garage);

                var success = await _context.SaveChangesAsync() > 0;

                if (success)
                {
                    return(Unit.Value);
                }

                throw new Exception("Problem saving changes");
            }
Exemple #5
0
 public void Delete(Vehicle vehicle)
 {
     _vehicleContext.Remove(vehicle);
     _vehicleContext.SaveChanges();
 }