public void MoveVehicle(Vehicle vehicle, int newParkingId)
 {
     using (var db = new PragueParkingContext())
     {
         db.Database.ExecuteSqlRaw("SP_MoveVehicle @p0,@p1", parameters: new Object[] { vehicle.Regnum, newParkingId });
         db.SaveChanges();
     }
 }
 public void RemoveVehicle(Vehicle vehicle)
 {
     using (var db = new PragueParkingContext())
     {
         db.Database.ExecuteSqlRaw("SP_CheckOut @p0", parameters: new[] { vehicle.Regnum });
         db.SaveChanges();
     }
 }
 public void InsertVehicle(string regnum, int type)
 {
     using (var db = new PragueParkingContext())
     {
         db.Database.ExecuteSqlRaw("SP_AddVehicle @p0, @p1", parameters: new Object[] { regnum, type });
         db.SaveChanges();
     }
 }
Exemplo n.º 4
0
        public List <int> FindEmptyParkingSpaces()
        {
            List <int> returnList = new();

            using (var db = new PragueParkingContext())
            {
                db.VDisplayEmptyParkingSpaces.ToList().ForEach(c => {
                    returnList.Add(c.ParkingSpaceId);
                });
                return(returnList);
            }
        }
        public List <Vehicle> GetAll()
        {
            List <Vehicle> vehicles = new List <Vehicle>();

            using (var db = new PragueParkingContext())
            {
                db.Occupieds.ToList().ForEach(c =>
                {
                    vehicles.Add(new Vehicle(c.RegNo, (VehicleTypeEnum)c.VehicleTypeId, c.Arrival, c.ParkingSpaceId));
                });
            }
            return(vehicles);
        }