public ItemsViewModel() { Title = "Browse"; Items = new ObservableCollection <Person>(); LoadItemsCommand = new Command(async() => await ExecuteLoadItemsCommand()); MessagingCenter.Subscribe <NewItemPage, Person>(this, "AddItem", async(obj, item) => { var newItem = item as Person; Items.Add(newItem); await DataStore.AddAsync(newItem); }); }
public AssetsViewModel() { Title = "Browse"; Assets = new ObservableCollection <Asset>(); LoadItemsCommand = new Command(async() => await ExecuteLoadItemsCommand()); MessagingCenter.Subscribe <NewAssetPage, Asset>(this, "AddAsset", async(obj, item) => { var _item = item as Asset; Assets.Add(_item); await DataStore.AddAsync(_item); }); }
public TransactionsViewModel(IDataStore <Entities.Transaction> dataStore, AutoMapper.IMapper mapper) : base(dataStore, mapper) { Title = "Browse"; Transactions = new ObservableCollection <TransactionModel>(); LoadTransactionsCommand = new Command(async() => await ExecuteLoadTransactionsCommand()); MessagingCenter.Subscribe <NewTransactionPage, TransactionModel>(this, "AddTransaction", async(obj, item) => { var newItem = item as TransactionModel; Transactions.Add(newItem); var entity = _mapper.Map <Entities.Transaction>(newItem); await DataStore.AddAsync(entity); }); }
public DepartmentsViewModel() { Title = "Departments"; Departments = new ObservableCollection <Department>(); LoadDepartmentsCommand = new Command(async() => await ExecuteLoadDeptsCommand()); MessagingCenter.Subscribe <NewDeptPage, Department>(this, "AddDept", async(obj, item) => { var newItem = item as Department; Departments.Add(newItem); await DataStore.AddAsync(newItem); await DataStore.SaveChangesAsync(); }); }
public async void AddColorAsync() { Models.Color c = new Models.Color { Colorcode = "#FF0000", Colorname = "Red", }; try { await DataStore.AddAsync(c); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
public async void AddColorAsync() { Mesearement m = new Mesearement { Height = 14, Width = 100, Depth = 50, }; try { await DataStore.AddAsync(m); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
public async void AddProductAsync() { Product p = new Product { Name = Name, ColorId = c.Id, MesearementId = m.Id, }; try { await DataStore.AddAsync(p); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
public ItemsViewModel() { Title = "Usuarios"; Usuarios = new ObservableCollection <Usuario>(); LoadItemsCommand = new Command(async() => await ExecuteLoadItemsCommand()); MessagingCenter.Subscribe <NewItemPage, Usuario>(this, "AddItem", async(obj, item) => { var newItem = item as Usuario; if (await DataStore.ExistsAsync(newItem)) { MessagingCenter.Send(this, "SendMessage", "El usuario ya existe."); return; } if (await DataStore.AddAsync(newItem)) { Usuarios.Add(newItem); } }); }
/// <summary> /// Using the image that the user has selected, attempt to analyze the photo and have it stored into the database. /// </summary> async void ProcessPictureInfo() { if (SelectedImage == null) { await Shell.Current.DisplayAlert("NO PICTURE", "No picture to process into a song.", "OK"); return; } if (photoAnalyzer == null) { throw new Exception("Did not set an analyzer with which to analyze with."); } photoAnalyzer.ClearData(); var resultMap = await photoAnalyzer.ProcessPictureInfoAsync(rawImage, detectFromPhotos); Song song = ConvertToSong(resultMap); if (song != null) // Put song into database { bool confirmAddition = await Shell.Current.DisplayAlert("Question", $"Is this info correct?\nSong Name: {song.Name}\nScore: {song.Score}", "YES", "NO"); // Interpolated string if (confirmAddition) { await DataStore.AddAsync(song); } } else // There's not enough data to build a song, tell user to retake a better photo or manually input. Save picture if this is the case. { await Shell.Current.DisplayAlert("FAILURE", "Could not add the song to the database.\nPlease either retake the photo or manually input.", "OK"); // Save file to gallery SavePhoto(); } }