public void PropertyChangedList() { HasLatestTransactions = LatestTransactions.Any(); HasLatestTransactionsFinished = LatestTransactionsFinished.Any(); HasLatestTransactionsLate = LatestTransactionsLate.Any(); HasLatestTransactionsOnGoing = LatestTransactionsOnGoing.Any(); OnPropertyChanged("TeHyrat"); OnPropertyChanged("AvailableCars"); OnPropertyChanged("TakenCars"); OnPropertyChanged("UnregisteredCars"); OnPropertyChanged("OnServiseCars"); OnPropertyChanged("LatestTransactionsOnGoing"); OnPropertyChanged("HasLatestTransactions"); OnPropertyChanged("HasLatestTransactionsFinished"); OnPropertyChanged("HasLatestTransactionsLate"); OnPropertyChanged("HasLatestTransactionsOnGoing"); HasTakenCars = TakenCars.Any(); OnPropertyChanged("HasTakenCars"); }
public async Task <Rent> LoadRentById(int id) { try { HttpClient httpClient = new HttpClient(); var response = await App.client.GetAsync(App.API_URL_BASE + "rents/" + id); if (response.StatusCode != System.Net.HttpStatusCode.OK) { UserDialogs.Instance.Alert("Probleme me server, Provoni Perseri", "Error", "Ok"); return(null); } else { var responseString = await response.Content.ReadAsStringAsync(); var Rent = JsonConvert.DeserializeObject <Rent>(responseString); var responseForRentedCars = await App.client.GetAsync(App.API_URL_BASE + "rentedcars/rent/" + Rent.Id); RentedCarsByRentId = JsonConvert.DeserializeObject <ObservableCollection <RentedCar> >(await responseForRentedCars.Content.ReadAsStringAsync()); if (RentedCarsByRentId != null) { var list = RentedCarsByRentId.OrderBy(i => i.DitetELeshimit); foreach (var item in list) { if (LatestTransactions.Count < 5) { LatestTransactions.Add(item); } if (item.KohaEKthimit > DateTime.Now && LatestTransactionsOnGoing.Count < 5 && !item.IsFinished) { LatestTransactionsOnGoing.Add(item); } if (item.KohaEKthimit < DateTime.Now && LatestTransactionsLate.Count < 5) { LatestTransactionsLate.Add(item); } if (item.IsFinished && LatestTransactionsFinished.Count < 5) { LatestTransactionsFinished.Add(item); } } var teHyrat = RentedCarsByRentId.ToList().FindAll(x => x.IsFinished && x.KohaELeshimit >= DateTime.Now.AddMonths(-1)); decimal count = 0.00m; foreach (var item in teHyrat) { count += (decimal)item.DitetELeshimit * item.CmimiDitor; } TeHyrat = count; } HasLatestTransactions = LatestTransactions.Any(); HasLatestTransactionsFinished = LatestTransactionsFinished.Any(); HasLatestTransactionsLate = LatestTransactionsLate.Any(); HasLatestTransactionsOnGoing = LatestTransactionsOnGoing.Any(); OnPropertyChanged("HasLatestTransactions"); OnPropertyChanged("HasLatestTransactionsFinished"); OnPropertyChanged("HasLatestTransactionsLate"); OnPropertyChanged("HasLatestTransactionsOnGoing"); return(Rent); } } catch (Exception e) { return(null); } }