public async Task AddRelationship(Artifact artifact, Category category) { // need to check if relationship already exists... if (!await DoesExist(artifact, category)) { var artifactRepo = new ArtifactRepository(); var categoryRepo = new CategoryRepository(); if (!await artifactRepo.DoesExist(artifact.ID)) { await artifactRepo.SaveAsync(artifact); } if (!await categoryRepo.DoesExist(category.ID)) { await categoryRepo.SaveAsync(category); } var newRelationship = new Artifact_Category { ArtifactID = artifact.ID, CategoryID = category.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); } }
public PresPg() { this.InitializeComponent(); _asalesbagRepo = new DataAccess.Repository.SalesBag_ArtifactRepository(); _salesbagRepo = new DataAccess.Repository.SalesBagRepository(); _meetingRepo = new DataAccess.Repository.MeetingRepository(); _artRepo = new DataAccess.Repository.ArtifactRepository(); _catRepo = new DataAccess.Repository.CategoryRepository(); }
/// The methods provided in this section are simply used to allow /// NavigationHelper to respond to the page's navigation methods. /// /// Page specific logic should be placed in event handlers for the /// <see cref="Common.NavigationHelper.LoadState"/> /// and <see cref="Common.NavigationHelper.SaveState"/>. /// The navigation parameter is available in the LoadState method /// in addition to page state preserved during an earlier session. protected override async void OnNavigatedTo(NavigationEventArgs e) { _categoryRepo = new DataAccess.Repository.CategoryRepository(); _artifactRepo = new DataAccess.Repository.ArtifactRepository(); var foo = await _categoryRepo.Search("cat"); navigationHelper.OnNavigatedTo(e); await UpdateUi(); await CheckForNewArtifacts(); }