Example #1
0
        public HttpResponseMessage Delete(int feedId)
        {
            try
            {
                var item = _repository.GetById(feedId);

                _repository.Delete(item);

                return(Request.CreateResponse(System.Net.HttpStatusCode.NoContent));
            }
            catch (System.Exception ex)
            {
                Exceptions.LogException(ex);
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message));
            }
        }
Example #2
0
 public ActionResult Delete([FromBody] string id)
 {
     if (id != null && _feedRepository.Delete(Guid.Parse(id)))
     {
         return(Ok());
     }
     return(BadRequest());
 }
Example #3
0
        public async Task DeleteFeed(
            string userName,
            string feedGroupName,
            string feedName
            )
        {
            var feedId = await
                         _feedRepository
                         .GetFeedId(
                userName,
                feedGroupName,
                feedName
                );

            await _feedRepository.Delete(feedId);
        }
Example #4
0
        static async Task Main(string[] args)
        {
            Console.OutputEncoding = System.Text.Encoding.UTF8;
            CommandsParser commandParser = new CommandsParser();
            IFeedService   feedService   = new FeedService();

            _feedRepository = new FeedXmlRepository();
            string[] arrString;
            //_feedRepository.Create(new Feed() { Name = "news", Url = "https://www.liga.net/news/rss.xml" });
            //_feedRepository.Create(new Feed() { Name = "articles", Url = "https://www.liga.net/news/articles/rss.xml" });
            //_feedRepository.Create(new Feed() { Name = "interview", Url = "https://www.liga.net/news/interview/rss.xml" });
            //_feedRepository.Create(new Feed() { Name = "opinion", Url = "https://www.liga.net/opinion/rss.xml" });
            //_feedRepository.Create(new Feed() { Name = "crypto", Url = "https://www.liga.net/fin/crypto/rss.xml" });
            //_feedRepository.Create(new Feed() { Name = "blog", Url = "https://www.liga.net/rss/blog.xml" });
            //_feedRepository.Create(new Feed() { Name = "vlog", Url = "https://www.liga.net/tech/vlog/rss.xml" });

            //_feedRepository.Create(new Feed() { Name = "news2.0", Url = "https://www.liga.net/news/rss.xml" });
            //var result = _feedRepository.GetAll();
            //var res = _feedRepository.GetByName("news2.0");
            //_feedRepository.Delete("news2.0");
            while (true)
            {
                do
                {
                    Console.Write("Enter the command->");
                }while (!commandParser.TryParse(Console.ReadLine(), out arrString));

                try
                {
                    switch (arrString[0].ToLower())
                    {
                    case "add":
                        _feedRepository.Create(new Feed {
                            Name = arrString[1], Url = arrString[2]
                        });
                        Console.WriteLine("Feed added");
                        break;

                    case "remove":
                        _feedRepository.Delete(arrString[1]);
                        Console.WriteLine("Feed removed");
                        break;

                    case "download":
                        var feeds = _feedRepository.GetAll();
                        if (feeds.Count == 0)
                        {
                            Console.WriteLine("XML-file with feeds is empty");
                            continue;
                        }
                        IList <string> names = new List <string>();
                        for (int i = 1; i < arrString.Length; i++)
                        {
                            if (feeds.Where(x => x.Name == arrString[i]).Count() > 0)
                            {
                                names.Add(feeds.Where(x => x.Name == arrString[i]).Select(x => x.Url).FirstOrDefault());
                            }
                        }
                        if (names.Count < 1)
                        {
                            Console.WriteLine("Nothing was found");
                            continue;
                        }

                        await feedService.Run(names.ToArray());

                        break;
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }
            }
            //var feeds = _feedRepository.GetAll();
            //string[] urls = feeds.Select(f => f.Url).ToArray();


            //await feedService.Run(urls);
        }
Example #5
0
 public void DeleteFeedItem(Feed item)
 {
     feedRepository.Delete(item);
 }
Example #6
0
 public ApiResponse <Feed> Delete(long id)
 {
     return(_feedRepository.Delete(id));
 }