private async void Button_Click(object sender, RoutedEventArgs e) { //DR - On button click, we want to hide and display the listbox // If the listbox is visible, collapse it. Otherwise... if (this.SalesBagComboBox.Visibility == Windows.UI.Xaml.Visibility.Visible) { this.SalesBagComboBox.Visibility = Windows.UI.Xaml.Visibility.Collapsed; } else { //DR - This is a bit hacky but in order to display a "New SalesBag" item in the listbox // we need to make a salesbag with the name "New SalesBag". Since the bag isn't saved into // the database we can do this every time the listbox is made visible. var emptyNewBag = new SalesBag(); emptyNewBag.Name = "[New SalesBag]"; //DR - emptySalesbag is made, make combobox visible, get the list of all salesbags this.SalesBagComboBox.Visibility = Windows.UI.Xaml.Visibility.Visible; List <SalesBag> salesBagList = await GetSalesBags(); //DR - Add the empty bag to the list and set as the box's item source // badabing badaboom salesBagList.Add(emptyNewBag); this.SalesBagComboBox.ItemsSource = salesBagList; } }
public async Task AddCategoryToSalesBag(Category category, SalesBag salesbag) { if (!await DoesExist(category, salesbag)) { var categoryRepo = new CategoryRepository(); var salesbagRepo = new SalesBagRepository(); if (!await categoryRepo.DoesExist(category.ID)) { await categoryRepo.SaveAsync(category); } if (!await salesbagRepo.DoesExist(salesbag.ID)) { await salesbagRepo.SaveAsync(salesbag); } var NewRelationship = new SalesBag_Category { Category = category.ID, SalesBag = salesbag.ID }; await SaveAsync(NewRelationship); } }
/// <summary> /// Maps the relationship between an artifact and a salesbag /// </summary> /// <param name="artifact"></param> /// <param name="salesbag"></param> /// <returns></returns> public async Task AddArtifactToSalesbag(Artifact artifact, SalesBag salesbag) { if (!await DoesExist(artifact, salesbag)) { var artifactRepo = new ArtifactRepository(); var salesbagRepo = new SalesBagRepository(); if (!await artifactRepo.DoesExist(artifact.ID)) { await artifactRepo.SaveAsync(artifact); } if (!await salesbagRepo.DoesExist(salesbag.ID)) { await salesbagRepo.SaveAsync(salesbag); } var newRelationship = new SalesBag_Artifact { Artifact = artifact.ID, SalesBag = salesbag.ID }; await SaveAsync(newRelationship); } }
/// <summary> /// Remove an artifact from a salesbag /// </summary> /// <param name="salesbag"></param> /// <param name="salesbag"></param> /// <returns></returns> public async Task RemoveArtifactFromSalesBag(Artifact artifact, SalesBag salesbag) { var relationships = await _database.Table <SalesBag_Artifact>().Where(x => (x.Artifact == artifact.ID) && (x.SalesBag == salesbag.ID)).ToListAsync(); foreach (var relationship in relationships) { await _database.DeleteAsync(relationship); } }
private void btnCreate_Click(object sender, RoutedEventArgs e) { _newSalesBag.DateCreated = DateTime.Now; _newSalesBag.Active = true; _salesBagRepo.SaveAsync(_newSalesBag); _newSalesBag = new SalesBag(); uxNewSalesBagPanel.DataContext = _newSalesBag; tbNewName.Text = ""; }
public async Task RemoveCategoryFromSalesBag(Category category, SalesBag salesbag) { var relationships = await _database.Table <SalesBag_Category>().Where(x => (x.Category == category.ID) && (x.SalesBag == salesbag.ID)).ToListAsync(); foreach (var relationship in relationships) { await _database.DeleteAsync(relationship); } }
/// <summary> /// Get all the Artifacts for a specified salesbag /// </summary> /// <param name="salesbag"></param> /// <returns></returns> public async Task <List <Artifact> > GetAllSalesBagArtifacts(SalesBag salesbag) { var relationships = await _database.Table <SalesBag_Artifact>().Where(x => x.SalesBag == salesbag.ID).ToListAsync(); var artifacts = new List <Artifact>(); foreach (var relationship in relationships) { artifacts.Add(await _database.FindAsync <Artifact>(relationship.Artifact)); } return(artifacts); }
public async Task <List <Category> > GetAllSalesBagCategories(SalesBag salesbag) { var relatinoships = await _database.Table <SalesBag_Category>().Where(x => x.SalesBag == salesbag.ID).ToListAsync(); var categories = new List <Category>(); foreach (var relationship in relatinoships) { categories.Add(await _database.FindAsync <Category>(relationship.Category)); } return(categories); }
public async Task CreateTestArtifactSalesBagRelationship() { await InitDb(); var artifact = new Artifact { Path = "test salesbag relationship", Title = "artfact for salesbag", FileName = "something.pdf", FileType = "pdf", DateAdded = DateTime.Now, Active = true }; var salesbag = new SalesBag { Name = "Im a salesbag!" }; var salesbagArtifact = new SalesBag_ArtifactRepository(); //add relationship here }
/// <summary> /// Checks if the artifact is already contained withinthe salesbag. /// </summary> /// <param name="artifact"></param> /// <param name="salesbag"></param> /// <returns></returns> public async Task <bool> DoesExist(Artifact artifact, SalesBag salesbag) { var relationships = await _database.Table <SalesBag_Artifact>().Where(x => (x.Artifact == artifact.ID) && (x.SalesBag == salesbag.ID)).CountAsync(); return(relationships > 0); }
private void Init() { _newSalesBag = new SalesBag(); _salesBagRepo = new SalesBagRepository(); uxNewSalesBagPanel.DataContext = _newSalesBag; }
public async Task DeleteAsync(SalesBag bag) { await _database.DeleteAsync(bag); }
public async Task SaveAsync(SalesBag bag) { await _database.InsertAsync(bag); }
public async Task <bool> DoesExist(Category category, SalesBag salesbag) { var relationships = await _database.Table <SalesBag_Category>().Where(x => (x.Category == category.ID) && (x.SalesBag == salesbag.ID)).CountAsync(); return(relationships > 0); }