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

                var src = Mapper.MapSource(country);
                if (src != null)
                {
                    var da   = new DataAccess();
                    var arts = da.GetArticles(src);
                    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));
                }
                else
                {
                    throw new NotImplementedException();
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex, "Attempt to get articles from country " + country.Country + " failed: " + ex.Message);
                return(BadRequest("Something went wrong while saving comment."));
            }
        }
        // Map ArticleCountry object to DAL.Source object
        public static Source MapSource(ArticleCountry country)
        {
            try
            {
                if (country == null)
                {
                    throw new NotImplementedException();
                }

                var src = new Source()
                {
                    Country = country.Country
                };

                return(src);
            }
            catch (Exception ex)
            {
                logger.Error(ex, "Attempt to map ArticleCountry " + country.Country + " to Source failed: " + ex.Message);
                return(null);
            }
        }
        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);
            }
        }