public async Task MakeRent() { var user = _user.GetUser(); if (CalculatedCost > user.Balance) { MessageBox.Show("Nie masz wystarczających środków na koncie."); } else { var rental = new VideoRental { DateCreated = DateTime.UtcNow, DateStart = SelectedDateFrom, DateEnd = SelectedDateTo, Price = CalculatedCost, VideoId = Movie.Id, AccountId = user.Id }; var addRentalResult = await _rentalRepo.AddRental(rental); var rechargeBalanceResult = await _accountRepo.RechargeBalance(user.Id, CalculatedCost, false); string message = addRentalResult && rechargeBalanceResult ? "Pomyślnie dodano wypożyczenie." : "Wystąpił błąd.\nSpróbuj ponownie"; MessageBox.Show(message); } }
public AccountSettingsViewModel(IAccountRepository accountRepo, ILoggedInUser user, IMapper mapper) { _accountRepo = accountRepo; _user = user; _mapper = mapper; User = _user.GetUser(); }
public async void Save() { if (Amount > 0) { var user = _user.GetUser(); var result = await _accountRepo.RechargeBalance(user.Id, Convert.ToDecimal(Amount)); if (result) { _events.PublishOnUIThread(new AccountBalanceRechargedEvent()); this.TryClose(); } else { MessageBox.Show("Wystąpił błąd, spróbuj ponownie."); } } }
private void LoadUserInfo() { User = _userService.GetUser(); }