Exemplo n.º 1
0
        public IList <Tag> GetAdvTags(Advert adv)
        {
            var        tagIds = _context.AdvTags.Where(p => p.AdvID == adv.Id).Select(p => p.TagId).ToList();
            List <Tag> tags   = new List <Tag>();

            foreach (var tagId in tagIds)
            {
                tags.Add(_context.Tags.Where(p => p.Id == tagId).FirstOrDefault());
            }
            return(tags);
        }
Exemplo n.º 2
0
        public IList <Category> GetAdvCategories(Advert adv)
        {
            var             categoryIds = _context.AdvCategories.Where(p => p.AdvID == adv.Id).Select(p => p.CatID).ToList();
            List <Category> categories  = new List <Category>();

            foreach (var catId in categoryIds)
            {
                categories.Add(_context.Categories.Where(p => p.Id == catId).FirstOrDefault());
            }
            return(categories);
        }
Exemplo n.º 3
0
        public IList <AdvImage> GetAdvImages(Advert adv)
        {
            var             advUrls = _context.AdvImages.Where(p => p.AdvId == adv.Id).ToList();
            List <AdvImage> images  = new List <AdvImage>();

            foreach (var url in advUrls)
            {
                images.Add(url);
            }
            return(images);
        }
Exemplo n.º 4
0
 public IList <Comment> GetAdvComments(Advert advert)
 {
     return(_context.Comments.Where(p => p.AdvId == advert.Id).ToList());
 }
Exemplo n.º 5
0
 public void AddNewAdvert(Advert advert)
 {
     _context.Adverts.Add(advert);
     Save();
 }