示例#1
0
        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);
            }
        }
        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);
            }
        }