Ejemplo n.º 1
0
 public RssService()
 {
     client         = new HttpClient();
     rssContext     = new RSSContext();
     channelService = new ChannelService(rssContext);
     itemService    = new ItemService(rssContext);
     parser         = new XmlParserToItem();
 }
Ejemplo n.º 2
0
        public List <Subscription> GetSubscriptions(String email)
        {
            try
            {
                using (var context = new RSSContext())
                {
                    return(context.Subscriptions.Where(x => x.Email == email).ToList());
                }
            }

            catch (Exception ex)
            {
                return(null);
            }
        }
Ejemplo n.º 3
0
        public Subscription GetSubscription(int id)
        {
            try
            {
                using (var context = new RSSContext())
                {
                    Subscription a = context.Subscriptions.Single(x => x.Id == id);
                    return(a);
                }
            }

            catch (Exception ex)
            {
                return(null);
            }
        }
Ejemplo n.º 4
0
        private void ShowChannels()
        {
            var context = new RSSContext();

            _service = new RSSService(
                new RSSPageParser(),
                new RSSReader(),
                new UnitOfWrok(context,
                               new Repository <RSSChannel>(context),
                               new Repository <RSSItem>(context)),
                "http://www.rss.lostsite.pl//index.php?rss=32");
            foreach (var item in _service.GetAllRSS())
            {
                listOfChannels.Items.Add(item);
            }
        }
Ejemplo n.º 5
0
        public bool SaveSubscription(Subscription subscription)
        {
            try
            {
                using (var context = new RSSContext())
                {
                    context.Subscriptions.Add(subscription);
                    context.SaveChanges();
                }
                return(true);
            }

            catch (Exception ex)
            {
                return(false);
            }
        }
Ejemplo n.º 6
0
        public bool RemoveSubscription(IEnumerable <int> idsToRemove)
        {
            try
            {
                using (var context = new RSSContext())
                {
                    foreach (int id in idsToRemove)
                    {
                        Subscription subscription = GetSubscription(id);
                        context.Remove(subscription);
                        context.SaveChanges();
                    }
                }
                return(true);
            }

            catch (Exception ex)
            {
                return(false);
            }
        }
Ejemplo n.º 7
0
        static void Main(string[] args)
        {
            if (args.Length < 1)
            {
                throw new Exception("need more params for start");
            }

            var command = args[0].ToLower();

            if (command == "add")
            {
                using (var context = new RSSContext())
                {
                    var repo = new cli.Repository.ChanelRepository(context);
                    repo.Create(new RSSChanel()
                    {
                        URL = args[1]
                    }).Wait();

                    Debug.WriteLine("command 1");
                }
            }
            else if (command == "update")
            {
                using (var context1 = new RSSContext())
                    using (var context2 = new RSSContext())
                    {
                        var chanelRepo = new cli.Repository.ChanelRepository(context1);
                        var rssRepo    = new cli.Repository.RSSRepository(context2);
                        var info       = new Observer(chanelRepo, rssRepo).Update().Result;

                        Console.WriteLine($"was added {info.Updated}\nwas checked {info.Checked}");
                        Debug.WriteLine("command 22");
                    }
            }
        }
Ejemplo n.º 8
0
 public ApiController(RSSContext rSSContext)
 {
     this._rssContext = rSSContext;
 }
Ejemplo n.º 9
0
 public ChannelService(RSSContext db)
 {
     this.db = db;
 }
Ejemplo n.º 10
0
 public ChanelRepository(RSSContext dbContext)
 {
     _dbContext = dbContext;
 }
Ejemplo n.º 11
0
 public EFUnitOfWork(string connectionString)
 {
     _dbcontext = new RSSContext(connectionString);
 }
Ejemplo n.º 12
0
 public RSSRepository(RSSContext dbContext)
 {
     _dbContext = dbContext;
 }
Ejemplo n.º 13
0
 public SourceRSSRepository(RSSContext context)
 {
     _dbcontext = context;
 }
Ejemplo n.º 14
0
 public ItemService(RSSContext db)
 {
     this.db = db;
 }
Ejemplo n.º 15
0
 public HomeController(RSSContext rSSContext)
 {
     this._rssContext = rSSContext;
 }
Ejemplo n.º 16
0
 public RSSItemRepository(RSSContext context)
 {
     _dbcontext = context;
 }