Пример #1
0
        public void AddCategory(FeedCategory toAdd)
        {
            var context = new RssAgregatorDataContext();

            context.FeedCategories.Add(toAdd);
            context.SaveChanges();
        }
Пример #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();
     }
 }
Пример #3
0
 public List<FeedCategory> GetAllCategories()
 {
     using (var context = new RssAgregatorDataContext())
     {
         return (from category in context.FeedCategories
                 select category).ToList();
     }
 }
Пример #4
0
 public List<FeedSource> GetAllSources()
 {
     using (var context = new RssAgregatorDataContext())
     {
         return (from source in context.FeedSources
             select source).ToList();
     }
 }
Пример #5
0
 public FeedCategory GetCategoryById(int id)
 {
     var context = new RssAgregatorDataContext();
     
         return (from category in context.FeedCategories
                 where category.Id == id
                 select category).SingleOrDefault();
     
 }
Пример #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();

        }
Пример #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();
     }
 }
Пример #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();
     }
 }
Пример #9
0
 public SourceManager()
 {
     Context = new RssAgregatorDataContext();
 }