Beispiel #1
0
        public VehicleEntity Create()
        {
            VehicleDb vehicle = new VehicleDb()
            {
                Owner  = DbModel.Owner,
                Model  = DbModel.Model,
                PosX   = DbModel.PosX,
                PosY   = DbModel.PosY,
                PosZ   = DbModel.PosZ,
                R      = DbModel.R,
                G      = DbModel.G,
                B      = DbModel.B,
                State  = false,
                Health = 1000
            };



            if (!_nonDbVehicle)
            {
                RoleplayContext ctx = Singleton.GetDatabaseInstance();
                using (UnitOfWork unitOfWork = new UnitOfWork(ctx))
                {
                    unitOfWork.VehicleRepository.Add(vehicle);
                }
            }


            return(new VehicleEntity(vehicle, _nonDbVehicle));
        }
Beispiel #2
0
 public VehicleEntity(VehicleDb model, bool nonDbVehicle = false)
 {
     DbModel       = model;
     _nonDbVehicle = nonDbVehicle;
 }
Beispiel #3
0
        public static VehicleDb GetVehicleDatabaseById(int id)
        {
            VehicleDb vehicle = Singleton.GetDatabaseInstance().Vehicles.Include(item => item.ItemsInVehicle).Include(upgrade => upgrade.VehicleUpgrades).SingleOrDefault(v => v.Id == id);

            return(vehicle);
        }