public IHttpActionResult Articles(ArticlePulished published)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest("Passed information isn't valid."));
                }

                var da   = new DataAccess();
                var arts = da.GetArticles(published.PublishedDate);
                if (arts == null)
                {
                    return(NotFound());
                }

                // Let's convert the article objects
                var articles = Mapper.MapArticle(arts);

                if (articles == null)
                {
                    throw new NotImplementedException();
                }

                return(Ok(articles));
            }
            catch (Exception ex)
            {
                logger.Error(ex, "Attempt to get articles from published date " + published.PublishedDate + " failed: " + ex.Message);
                return(BadRequest("Something went wrong while saving comment."));
            }
        }
        private HttpRequestMessage CreateSearchRequestToService(Search search)
        {
            try
            {
                HttpRequestMessage requestMessage = CreateRequestToService(HttpMethod.Post, "api/Data/" + search.Criteria);
                if (search.Criteria == "Title")
                {
                    var at = new ArticleTitle()
                    {
                        Title = search.SearchString
                    };
                    requestMessage.Content = new ObjectContent <ArticleTitle>(at, new JsonMediaTypeFormatter());
                }
                else if (search.Criteria == "Topic")
                {
                    var at = new ArticleTopic()
                    {
                        Topic = search.SearchString
                    };
                    requestMessage.Content = new ObjectContent <ArticleTopic>(at, new JsonMediaTypeFormatter());
                }
                else if (search.Criteria == "Source")
                {
                    var at = new ArticleSource()
                    {
                        Name = search.SearchString
                    };
                    requestMessage.Content = new ObjectContent <ArticleSource>(at, new JsonMediaTypeFormatter());
                }
                else if (search.Criteria == "Country")
                {
                    var at = new ArticleCountry()
                    {
                        Country = search.SearchString
                    };
                    requestMessage.Content = new ObjectContent <ArticleCountry>(at, new JsonMediaTypeFormatter());
                }
                else if (search.Criteria == "Language")
                {
                    var at = new ArticleLanguage()
                    {
                        Language = search.SearchString
                    };
                    requestMessage.Content = new ObjectContent <ArticleLanguage>(at, new JsonMediaTypeFormatter());
                }
                else if (search.Criteria == "Date")
                {
                    var at = new ArticlePulished()
                    {
                        PublishedDate = Convert.ToDateTime(search.SearchString)
                    };
                    requestMessage.Content = new ObjectContent <ArticlePulished>(at, new JsonMediaTypeFormatter());
                }

                return(requestMessage);
            }
            catch (Exception ex)
            {
                // log the error here
                logger.Error(ex.Message);
                return(null);
            }
        }