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"); }
private async Task KtheVeturenAsync() { using (UserDialogs.Instance.Loading("Loading")) { CurrentRentedCar.KohaAktualeEKthimit = DateTime.Now; var json = JsonConvert.SerializeObject(CurrentRentedCar); App.client.DefaultRequestHeaders.TryAddWithoutValidation("Content-Type", "application/json"); HttpContent httpContent = new StringContent(json, Encoding.UTF8, "application/json"); var response = await App.client.PutAsync(App.API_URL_BASE + "rentedcars/update", httpContent); if (response.IsSuccessStatusCode) { //UserDialogs.Instance.Alert("Vetura u kthye me sukses", "Sukses", "OK"); } else { //UserDialogs.Instance.Alert("Vetura nuk u kthye me sukses", "Error", "OK"); IsSuccess = false; return; } var responseString = await response.Content.ReadAsStringAsync(); RentedCar addedCar = JsonConvert.DeserializeObject <RentedCar>(responseString); IsSuccessfullRent = addedCar != null ? true : false; var page = new PostRentedCarPage(); page.BindingContext = this; IsSuccess = true; var car = TakenCars.FirstOrDefault(x => x.Id == addedCar.CarId); LatestTransactionsFinished.Add(addedCar); LatestTransactionsOnGoing.Remove(addedCar); if (LatestTransactionsFinished.Count > 5) { App.instance.DashboardViewModel.LatestTransactions.RemoveAt(0); } RentedCarsByRentId.Remove(CurrentRentedCar); RentedCarsByRentId.Add(addedCar); 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; OnPropertyChanged("TeHyrat"); car.Statusi = Car.StatusTypes.Aktiv; car.Km = CurrentRentedCar.KilometrazhiAktual; AvailableCars.Add(car); TakenCars.Remove(car); var ongoing = LatestTransactionsOnGoing.FirstOrDefault(x => x.Id == addedCar.Id); if (ongoing != null) { LatestTransactionsOnGoing.Remove(ongoing); } OnPropertyChanged("LatestTransactionsOnGoing"); HasTakenCars = TakenCars.Any(); HasAvailableCars = AvailableCars.Any(); OnPropertyChanged("HasTakenCars"); await Task.Delay(500); App.instance.ChangeDetailPage(page); } }