Exemple #1
0
        public void AddCategory(FeedCategory toAdd)
        {
            var context = new RssAgregatorDataContext();

            context.FeedCategories.Add(toAdd);
            context.SaveChanges();
        }
Exemple #2
0
 public List<FeedCategory> GetCategoriesNumber(int number = 5)
 {
     using (var context = new RssAgregatorDataContext())
     {
         return (from category in context.FeedCategories
                 select category).Take(number).ToList();
     }
 }
Exemple #3
0
 public List<FeedCategory> GetAllCategories()
 {
     using (var context = new RssAgregatorDataContext())
     {
         return (from category in context.FeedCategories
                 select category).ToList();
     }
 }
Exemple #4
0
 public List<FeedSource> GetAllSources()
 {
     using (var context = new RssAgregatorDataContext())
     {
         return (from source in context.FeedSources
             select source).ToList();
     }
 }
Exemple #5
0
 public FeedCategory GetCategoryById(int id)
 {
     var context = new RssAgregatorDataContext();
     
         return (from category in context.FeedCategories
                 where category.Id == id
                 select category).SingleOrDefault();
     
 }
Exemple #6
0
        public List<FeedCategory> GetByUserId(string id)
        {
            var context = new RssAgregatorDataContext();

            return (from category in context.FeedCategories
                where category.UserId == id
                select category).ToList();

        }
Exemple #7
0
 public void DeleteCategory(FeedCategory toDelete)
 {
     using (var context = new RssAgregatorDataContext())
     {
         FeedCategory cat = (FeedCategory)context.FeedCategories.Where(b => b.Id == toDelete.Id).First();
         context.FeedCategories.Remove(cat);
         context.SaveChanges();
     }
 }
Exemple #8
0
 public void RenameModel(int categoryId, string newName)
 {
     using (var context = new RssAgregatorDataContext())
     {
         var fromDbToUpdate = (from cate in context.FeedCategories
                               where cate.Id == categoryId
                               select cate).Single();
         fromDbToUpdate.Name = newName;
         context.SaveChanges();
     }
 }
Exemple #9
0
 public SourceManager()
 {
     Context = new RssAgregatorDataContext();
 }