private void AddPayment(object param) { decimal amount; bool isAmountValid = decimal.TryParse(this.PaymentAmount, out amount); if (!isAmountValid || !IsValid(this as DependencyObject)) { AmountError = "Niepoprawna kwota"; return; } var mpdg = new MultiPaymentDataGrid() { PaymentId = null, Apartment = SelectedApartmentNumber, Building = SelectedBuildingName, ChargeGroup = SelectedGroupName, Owner = _selectedOwner, PaymentAddDate = DateTime.Now, PaymentAmount = amount, PaymentRegistrationDate = PaymentRegistrationDate, }; PaymentsList.Add(mpdg); }
public async Task Init() { if (PaymentsList.Count > 0) { PaymentsList.Clear(); Total = 0; } var clients = await _userService.GetAll <List <User> >(new UserSearchRequest { Username = APIService.Username }); var client = clients[0]; var payments = await _paymentService.GetAll <List <Payment> >(new PaymentSearchRequest { UserID = client.UserID }); foreach (var payment in payments) { PaymentsList.Add(payment); Total += payment.Amount; } }
private void AcceptDialog(object obj) { if (SelectedHouse == null) { AddError(nameof(SelectedHouse), "Field cannot be empty"); } if (string.IsNullOrEmpty(HeatMeter)) { AddError(nameof(HeatMeter), "Field cannot be empty"); } if (string.IsNullOrEmpty(Cost)) { AddError(nameof(Cost), "Field cannot be empty"); } if (!HasErrors) { var payment = new Payment { Date = DateTime.Now, Cost = Convert.ToInt32(Cost), HeatMeter = Convert.ToInt32(HeatMeter) }; var user = context.Users.FirstOrDefault(u => u.Id == UserId); var house = context.Houses.FirstOrDefault(u => u.Id == SelectedHouse.Id); house.HeatMeter = Convert.ToInt32(HeatMeter); payment.User = user; payment.House = house; PaymentsList.Add(payment); context.SaveChanges(); SelectedHouse = null; IsDialogOpen = false; } }
public async Task Init() { if (PaymentsList.Count > 0) { PaymentsList.Clear(); Total = 0.00f; } search_request.Username = APIService.Username; var candidates = await _candidateService.GetAll <List <Candidate> >(search_request); var candidate = candidates[0]; search_request2.CandidateId = candidate.Id; var payments = await _paymentService.GetAll <List <Payment> >(search_request2); foreach (var payment in payments) { var category = await categoryService.GetById <Category>(payment.CategoryId); payment.Category = category.Name; PaymentsList.Add(payment); Total += payment.Amount; } }