/// <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 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); } }