Exemplo n.º 1
0
        public void LinkNewsItemToCategoryById(int cid, int nid)
        {
            var link = new NewsItemCategories
            {
                CategoryId = cid,
                NewsItemId = nid
            };

            DataProvider.NewsItemCategories.Add(link);
        }
Exemplo n.º 2
0
        public void LinkNewsItemToCategory(int categoryId, int newsItemId)
        {
            var entity = new NewsItemCategories
            {
                CategoryId = categoryId,
                NewsItemId = newsItemId
            };

            DataProvider.NewsItemCategories.Add(entity);
        }
        public void CreateNewsItemCategoryLink(int categoryId, int newsItemId)
        {
            var entity = new NewsItemCategories
            {
                CategoryId = categoryId,
                NewsItemId = newsItemId
            };

            DataProvider.NIC.Add(entity);
        }
Exemplo n.º 4
0
        public void ConnectNewsIdByCategoryId(int categoryid, int newsitemid)
        {
            var entity = new NewsItemCategories
            {
                CategoryId = categoryid,
                NewsItemId = newsitemid
            };

            DataProvider.NewsItemsCategories.Add(entity);
        }
Exemplo n.º 5
0
        public void LinkNewsItemToCategoryById(int cid, int nid)
        {
            var link = new NewsItemCategories
            {
                CategoryId = cid,
                NewsItemId = nid
            };

            FakeDatabase.NewsItemCategories.Add(link);
        }
Exemplo n.º 6
0
        public void CreateNewsItemCategoryRelation(int categoryId, int newsItemId)
        {
            var category = DataProvider.Categories.FirstOrDefault(c => c.Id == categoryId);
            var newsItem = DataProvider.NewsItems.FirstOrDefault(n => n.Id == newsItemId);

            if (category == null || newsItem == null)
            {
                throw new KeyNotFoundException();
            }
            var relation = new NewsItemCategories();

            relation.CategoryId = categoryId;
            relation.NewsItemId = newsItemId;
            DataProvider.NewsItemCategories.Add(relation);
        }
Exemplo n.º 7
0
        public void ConnectNewsItemToCategory(int categoryId, int newsItemId)
        {
            NewsItemCategories newConnection = new NewsItemCategories {
                CategoryId = categoryId, NewsItemId = newsItemId
            };

            //Checking if connection is already made
            var exists = CategoryNewsItemLinkDataProvider.CategoryNewsItemLink
                         .FirstOrDefault(i => i.NewsItemId == newsItemId && i.CategoryId == categoryId);

            if (exists != null)
            {
                throw new ConnectionExistsException("Connection already exists!");
            }
            CategoryNewsItemLinkDataProvider.CategoryNewsItemLink.Add(newConnection);
        }
        public void LinkCategory(int categoryId, int newsItemId)
        {
            if (DataProvider.Categories.FirstOrDefault(n => n.Id == categoryId) == null)
            {
                throw new ResourceNotFoundException($"Category with id {categoryId} was not found.");
            }
            if (DataProvider.NewsItems.FirstOrDefault(n => n.Id == newsItemId) == null)
            {
                throw new ResourceNotFoundException($"News item with id {newsItemId} was not found.");
            }
            var newLink = new NewsItemCategories
            {
                CategoryId = categoryId,
                NewsItemId = newsItemId
            };

            DataProvider.newsItemCategories.Add(newLink);
        }
Exemplo n.º 9
0
        public bool ConnectNewsItemToCategory(int categoryId, int newsItemId)
        {
            var categoryEntity = DataProvider.Categories.FirstOrDefault(r => r.Id == categoryId);
            var newsItemEntity = DataProvider.Categories.FirstOrDefault(r => r.Id == newsItemId);

            if (categoryEntity == null || newsItemEntity == null)
            {
                return(false);
            }

            NewsItemCategories newsItemCategory = new NewsItemCategories
            {
                CategoryId = categoryEntity.Id,
                NewsItemId = newsItemEntity.Id
            };

            DataProvider.NewsItemCategories.Add(newsItemCategory);
            return(true);
        }
        public void LinkNewsItemToCategory(int newsItemId, int categoryId)
        {
            var newsEntity = NewsItemDataProvider.NewsItems.FirstOrDefault(n => n.Id == newsItemId);

            if (newsEntity == null)
            {
                throw new ResourceNotFoundException($"News with id: {newsItemId} was not found");
            }
            var categoryEntity = CategoryDataProvider.Categories.FirstOrDefault(c => c.Id == categoryId);

            if (categoryEntity == null)
            {
                throw new ResourceNotFoundException($"Category with id: {categoryId} was not found");
            }
            var item = new NewsItemCategories
            {
                CategoryId = categoryId,
                NewsItemId = newsItemId
            };

            NewsItemCategoriesDataProvider.NewsItemCategories.Add(item);
        }