private void RegisterRaceStarterCar(StarterConfigInputs config, int trackIndex) { RaceStarterModel racer = RacingCarsFactory.MakeRaceStarter(config); DataCenter.RegisterRaceStarters(racer); RacingCarsFactory.InstantiateCarObject(racer, trackIndex); UserCarSettings userSettings = RacingCarsFactory.MakeUserSettings(config, racer.RaceStarterId); Repository.SaveCarStartersConfigs(userSettings); }
public static UserCarSettings MakeUserSettings(StarterConfigInputs starterInputConfigs, string starterCarId) { var userConfig = new UserCarSettings(); userConfig.StarterCarId = starterCarId; userConfig.BrandSelected = (BrandModel.BrandModelType)starterInputConfigs.SelectCarBranModelDdl.value; userConfig.ColorSelected = (ColorModel.BodyColor)starterInputConfigs.SelectCarColorDdl.value; userConfig.TireSelected = (TireModel.TireType)starterInputConfigs.SelectCarTireDdl.value; userConfig.VehicleBodySelected = (VehicleBodyModel.VehicleType)starterInputConfigs.SelectCarBodyDdl.value; userConfig.EngineSelected = (EngineModel.EngineType)starterInputConfigs.SelectCarEngineDdl.value; return(userConfig); }
//saves to database or updates of if it's already saved public static void SaveCarStartersConfigs(UserCarSettings setting) { var fromDatabase = DataService.GetConfigById(setting.StarterCarId); if (fromDatabase == null) { DataService.AddItemToStoragTable(typeof(UserCarSettings), setting); } else { setting.Id = fromDatabase.Id; DataService.UpdateAlreadyStoredItem(typeof(UserCarSettings), setting); } }