Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var shopVehicle = _uow.UpShopVehicleRepository.GetVehicleByModel(vName);
- var user = GetUser(player);
- var countCars = _uow.VRPUserVehiclesRepository.CountByUserId(user.VrpUserId);
- var existsVehicle = _uow.VRPUserVehiclesRepository.GetVehicleByUserName(user.VrpUserId, shopVehicle.Model);
- if (shopVehicle.Avaible == 0 || !shopVehicle.Enable)
- {
- ShowAlert(player, "Não existe estoque para o veículo selecionado.");
- return;
- }
- if (user.UpVip.Garages < (countCars + 1))
- {
- ShowAlert(player, "Você atingiu o número máximo de veículos em sua garagem.");
- return;
- }
- if(existsVehicle != null)
- {
- ShowAlert(player, "Você já possui um veículo desse modelo em sua garagem.");
- return;
- }
- using (var transaction = _uow.BeginTransaction())
- {
- try
- {
- if (MakePayment(player, shopVehicle.Price))
- {
- shopVehicle.Avaible--;
- var userVehicle = new VRPUserVehicles
- {
- detido = false,
- HealthBody = 1000,
- HealthVehicle = 1000,
- UserId = user.VrpUserId,
- Vehicle = shopVehicle.Model
- };
- _uow.VRPUserVehiclesRepository.Add(userVehicle);
- _uow.Commit();
- _uow.VRPUserVehiclesRepository.Dettach(userVehicle);
- transaction.Commit();
- ShowAlert(player, $"Você pagou ^1$ {shopVehicle.Price.ToString("N0")} ^0dólares.");
- }
- }
- catch (Exception ex)
- {
- Debug.WriteLine(ex.Message);
- transaction.Rollback();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement