/* Day Selected */ private void DaySelected(object parameter) { try { //Hide Calender ShowHideCalender(); List <CalenderWeekAndDay> listCalenderDays = new List <CalenderWeekAndDay>(); var day = Convert.ToString(parameter); //Logic for selecting/deSelecting dates in calender var item = listCalenderMonthDated.FirstOrDefault(i => i.Day == day); if (item != null) { item.Selected = true; } listCalenderMonthDated.Where(i => i.Day != day).ToList().ForEach(d => { d.Selected = false; }); DateTimeFormatInfo mfi = new DateTimeFormatInfo(); lblCurrentDay = day + " " + mfi.GetMonthName(currentMonth).Substring(0, 3) + " " + DateTime.Now.ToString("yyyy"); //Set Visits for Day Selected _apiService.GetAllVisitsbyDate(new DateTime(DateTime.Now.Year, currentMonth, Convert.ToInt32(day))); //Get Visits Using Infinite Scrolling Logic, 5 at a time LoadItemsCommand.Execute(null); } catch (Exception ex) { _errorLoggerService.SaveErrorInDatabase("DaySelected", "CleaningListPage", ex.Message); } }
public void SubscribeMessaginCenterEvents() { MessagingCenter.Subscribe <NewProductPage, Product>(this, "AddItem", async(obj, product) => { var newProduct = product as Product; Products.Add(newProduct); await DataStore.AddItemAsync(newProduct); }); MessagingCenter.Subscribe <ProductEditPage, Product>(this, "EditItem", async(obj, product) => { var editedProduct = product as Product; await DataStore.UpdateItemAsync(editedProduct); LoadItemsCommand.Execute(null); }); MessagingCenter.Subscribe <ProductDetailPage, Product>(this, "DeleteItem", async(obj, product) => { var productForDeletion = product as Product; Products.Remove(productForDeletion); await DataStore.DeleteItemAsync(productForDeletion.Id); }); }
protected void Filter_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { if (e.PropertyName == "Index") { LoadItemsCommand.Execute(null); } }
async void OnAlertYesNoClicked(object obj) { if (Items.Count == 0) { LoadItemsCommand.Execute(null); } var answer = await App.Current.MainPage.DisplayAlert("Question?", "Would you like to add " + (obj as Artiste).Pseudo + " to your list ?", "Yes", "No"); Debug.WriteLine("Answer: " + answer); if (answer) { if (Items.Any(artiste => artiste.Pseudo.ToUpper() == (obj as Artiste).Pseudo.ToUpper())) { Debug.WriteLine("Your have already added" + (obj as Artiste).Pseudo + " to your list."); DependencyService.Get <IMessageToast>() .ShortAlert("Your have already added " + (obj as Artiste).Pseudo + " to your list."); } else { await DataStore.AddItemAsync((obj as Artiste)); Items.Add((obj as Artiste)); Debug.WriteLine("Successfully added " + (obj as Artiste).Pseudo + " to your list"); DependencyService.Get <IMessageToast>() .ShortAlert("Successfully added " + (obj as Artiste).Pseudo + " to your list"); } } }
async public Task <bool> DeleteVehicleMake(VehicleMake v) { var deleted = await iVehicleMakeService.DeleteVehicle(v); LoadItemsCommand.Execute(null); return(deleted); }
//ZM: This code is run every time the attached View appears public void OnViewAppearing(object sender, EventArgs e) { if (Items.Count == 0) { LoadItemsCommand.Execute(null); } }
public MeetingsViewModel(MeetingType meetingType = MeetingType.Meeting) { Meetings = new ObservableCollection <Meeting>(); type = meetingType; LoadItemsCommand.Execute(null); }
public OfficersViewModel(int level = 0) { Officers = new ObservableCollection <Officer>(); Level = level; LoadItemsCommand.Execute(null); }
public MembersPageViewModel() { Members = new ObservableCollection <Member>(); LoadItemsCommand.Execute(null); }
public override void OnViewAppearing() { base.OnViewAppearing(); if (Podcasts.Count == 0) { LoadItemsCommand.Execute(null); } }
private async void ShowErrorConection(string msg) { var result = await Application.Current.MainPage.DisplayAlert("Error", msg, "Retry", "Cancel"); if (result == true) { LoadItemsCommand.Execute(null); } }
protected override void OnFirstAppear() { base.OnFirstAppear(); if (Items.Count == 0) { LoadItemsCommand.Execute(null); } }
public void RemoveApartment() { if (ApartmentsJson.Count <= 2) { LoadItemsCommand.Execute(null); } ApartmentsJson.RemoveAt(0); m_Apartment.DeserializeApart(ApartmentsJson[0]); }
public HomeViewModel() { var preferenceTheme = MaterialColor.NiceCombinationList.FirstOrDefault(x => x.Name.Equals(PreferenceService.ThemePreference)); App.LoadTheme(preferenceTheme); ResetProps(); LoadItemsCommand.Execute(null); }
private void OnItemAppearing(object sender, ItemVisibilityEventArgs e) { var listview = (ListView)sender; if (listview.IsRefreshing) { return; } if (LoadItemsCommand == null) { return; } //TODO //Any() TO AnyExtended() if (!((IEnumerable <object>)StemmonsListViewStaticItems).Any()) { return; } int currentIndex = e.ItemIndex; int lastItemIndex = ((IEnumerable <object>)StemmonsListViewStaticItems).Count() - 1; var lastItem = ((IEnumerable <object>)StemmonsListViewStaticItems).ElementAt(lastItemIndex); bool isLast = false; if (listview.IsGroupingEnabled) { if (((IEnumerable <object>)lastItem).Any()) { int totalCount = 0; foreach (var item in ((IEnumerable <object>)StemmonsListViewStaticItems)) { totalCount += ((IEnumerable <object>)item).Count(); } totalCount += ((IEnumerable <object>)StemmonsListViewStaticItems).Count() - 1; isLast = totalCount == currentIndex; } } else { isLast = lastItemIndex == currentIndex; } if (isLast) { lstFooter.IsVisible = true; LoadItemsCommand.Execute(e.Item); } }
public void FilterList(string query) { if (string.IsNullOrWhiteSpace(query)) { LoadItemsCommand.Execute(null); return; } else { Entries = new ObservableCollection <PhoneBookEntry>( Entries.Where(x => x.FirstName.ToLowerInvariant().Contains(query.ToLowerInvariant()) || x.Surname.ToLowerInvariant().Contains(query.ToLowerInvariant()))); OnPropertyChanged(nameof(Entries)); } }
private async Task OnDeleteClicked(VehicleModel v) { var deletedVehicleName = await DeleteVehicleModel(v.dataBaseId, false); if (deletedVehicleName != null) { await DisplayAlert("Alert", "Vehicle " + deletedVehicleName + " deleted", "OK"); LoadItemsCommand.Execute(null); } else { await DisplayAlert("Alert", "Vehicle not deleted", "OK"); LoadItemsCommand.Execute(null); } }
public ItemsViewModel() { if (Items?.Count == 0) { LoadItemsCommand.Execute(null); } Title = "Browse"; Items = new ObservableCollection <Item>(); LoadItemsCommand = new Command(async() => await ExecuteLoadItemsCommand()); AddItemCommand = new Command(async() => await NavigationService.NavigateToAsync <NewItemViewModel>(this)); MessagingCenter.Subscribe <NewItemView, Item>(this, "AddItem", async(obj, item) => { var newItem = item as Item; Items.Add(newItem); await DataStore.AddItemAsync(newItem); }); }
public async void PickerValidated(Artiste a) { if (Items.Any(artiste => artiste.Pseudo.ToUpper() == a.Pseudo.ToUpper())) { Debug.WriteLine("Your have already added" + a.Pseudo + " to your list."); DependencyService.Get <IMessageToast>() .ShortAlert("Your have already added " + a.Pseudo + " to your list."); } else { await DataStore.AddItemAsync(a); Items.Add(a); Debug.WriteLine("Successfully added " + a.Pseudo + " to your list"); LoadItemsCommand.Execute(null); DependencyService.Get <IMessageToast>().ShortAlert("Successfully added " + a.Pseudo + " to your list"); } }
public ProfileViewModel() { LoadItemsCommand.Execute(null); }
public void OnResume() { LoadItemsCommand.Execute(null); }
public PlacesViewModel(int level = 0) { Places = new ObservableCollection <Place>(); LoadItemsCommand.Execute(null); }
public HomePageViewModel() { Announcements = new ObservableCollection <Announcement>(); LoadItemsCommand.Execute(null); }
private void OnNewDigitizedCard(NewDigitizedCard newCard) { LoadItemsCommand.Execute(null); }
void ExecuteDeleteCardCommand(DigitizedCard digitizedCard) { DependencyService.Get <IDigitizedCardService>().Delete(digitizedCard); LoadItemsCommand.Execute(null); }
//XFMA - Handles the Page.Appearing event //right here in the ViewModel public override void OnViewAppearing(object sender, EventArgs e) { LoadItemsCommand.Execute(null); }
public void OnAppearing() { IsBusy = true; LoadItemsCommand.Execute(null); }
public CalendarViewModel() { CalendarMeetings = new ObservableCollection <Meeting>(); LoadItemsCommand.Execute(null); }
public void SetOrder(bool order) { Order = order; OrderName = Order ? "DESC" : "ASC"; LoadItemsCommand.Execute(null); }
public CategoriesViewModel(HttpClient client) { CatList = new ObservableCollection <Category>(); Products = new ObservableCollection <AppItem>(); SubCats = new ObservableCollection <Subcategory>(); items = new List <AppItem>(); data = new List <Category>(); MainProduct = new AppItem(); GetCartCountCommand = new Command(async() => { var cart = await DataBase.GetAllStreamAsync <Models.CartItem>("Cart"); var Count = 0; foreach (var item in cart) { Count += item.Count; } this.CartCount = Count; }); LoadSubcat = new Command(async(subcat) => { var items = DataBase.GetByQueryEnumerable <AppItem>("Items", Query.Where("category", x => x.AsArray.Contains((int)subcat))); if (Products == null) { Products = new ObservableCollection <AppItem>(); } Products.Clear(); if (items != null) { while (items.MoveNext()) { await Task.Delay(TimeSpan.FromMilliseconds(200)); Products.Add(items.Current); } } }); LoadCategoriesCommand = new Command(async() => { if (DataBase.GetRecordCount <CategorySimplified>("Categories") == 0) { data = await RequestHelper.GetData <List <Category> >(client, "data/app_categs_full20.php?version="); } CatList.Clear(); var categories = new List <CategorySimplified>(); if (data.Count > 0) { foreach (var category in data) { categories.Add(new CategorySimplified(category)); } DataBase.WriteAll <CategorySimplified>("Categories", categories); foreach (Category category in data) { category.image = "https://www.tokyo-city.ru" + category.image; CatList.Add(category); } CurrentCategory = CatList[0].id; LoadItemsCommand.Execute(null); } else { var categs = await DataBase.GetAllStreamAsync <CategorySimplified>("Categories"); var ie = categs.GetEnumerator(); while (ie.MoveNext()) { CatList.Add(new Category(ie.Current)); } } }); LoadItemsCommand = new Command(async() => { await Task.Run(() => LoadItemsMethod(client)); }); LoadCategoryItemsCommand = new Command(async() => { int count = DataBase.GetRecordCount <AppItem>("Items"); var query = Query.Where("category", category => category.AsArray.Contains(CurrentCategory)); var itemsFound = DataBase.GetByQueryEnumerable <AppItem>("Items", query); SubCats.Clear(); if (CatList[CategoryIndex].subcategories?.Count > 0) { foreach (var subcat in CatList[CategoryIndex].subcategories) { SubCats.Add(subcat); } } Products.Clear(); List <AppItem> tempList = new List <AppItem>(); while (itemsFound.MoveNext()) { await Task.Delay(TimeSpan.FromMilliseconds(200)); Products.Add(itemsFound.Current); } itemsFound.Dispose(); }); LoadFirstItemCommand = new Command(() => { MainProduct = DataBase.GetOneOfCategory <AppItem>("Items", CurrentCategory); }); }