Example #1
0
        static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                Console.Out.WriteLine("You need to enter a command in arguments");
                return;
            }

            DataService dataService = new DataService();
            FeedService feedService = new FeedService();
            UserService userService = new UserService();

            switch (args[0])
            {
            case "-addfeed":
                if (args.Length != 3)
                {
                    Console.Out.WriteLine("Incorrect number of parameters");
                }

                bool result = dataService.AddFeed(args[1], args[2]);
                Console.Out.WriteLine("New feed successfully added");
                break;

            case "-refreshfeeds":
                int feedsCount = feedService.RefreshFeeds();
                Console.Out.WriteLine("{0} new feed items added", feedsCount);
                break;

            case "-getlabels":
                feedService.ExtractAllLabels();
                Console.Out.WriteLine("Labels are successfully extracted");
                break;

            case "-testfeeds":
                TestFeeds(feedService);
                Console.In.ReadLine();
                break;

            case "-testfeeditems":
                TestFeedItems(feedService);
                Console.In.ReadLine();
                break;

            case "-adduser":
                if (args.Length != 2)
                {
                    Console.Out.WriteLine("Incorrect number of parameters");
                }
                userService.AddUser(args[1]);
                Console.Out.WriteLine("New user successfully added");

                break;

            case "-likedoc":
                if (args.Length != 3)
                {
                    Console.Out.WriteLine("Incorrect number of parameters");
                }
                FeedItem document = feedService.GetDocument(args[2]);
                if (document == null)
                {
                    Console.Out.WriteLine("Document was not found");
                }

                userService.LikeDocument(args[1], document);
                Console.Out.WriteLine("Document was successfully liked");
                break;
            }

            //TestFeeds();
            //TestFeedItems();

            //Console.In.ReadLine();
        }