public IEnumerable <get_Articles> Post_Shared_Articles([FromBody] user_article_input article) { List <get_shared_article_Result> articleList = new List <get_shared_article_Result>(); List <get_Articles> finalArticleList = new List <get_Articles>(); using (var articles = db.get_shared_article(article.uid, article.category, article.sub_category)) { articleList = articles.ToList <get_shared_article_Result>(); } foreach (var item in articleList) { get_Articles post = new get_Articles(); post.serial_no = item.serial_no.GetValueOrDefault(); post.a_id = item.a_id.GetValueOrDefault(); post.title = item.title; post.site_url = item.site_url; post.site_name = getSiteName(post.site_url); post.photo_url = item.photo_url; post.modified_date = item.modified_date.GetValueOrDefault(); post.category = item.category; post.url = item.url; post.summary = item.summary; post.custom = item.custom.GetValueOrDefault(); post.copied = item.copied; post.shared = item.shared; post.sub_category = item.sub_category; post.shares = 0; post.views = "0"; finalArticleList.Add(post); } return(finalArticleList); }
public IEnumerable <get_Articles> PostArticles([FromBody] user_article_input article) { List <get_articles_Result> articleList = new List <get_articles_Result>(); List <get_Articles> finalArticleList = new List <get_Articles>(); using (var articles = db.get_articles(article.uid, article.category, article.sub_category)) { articleList = articles.ToList <get_articles_Result>(); } foreach (var item in articleList) { get_Articles post = new get_Articles(); post.serial_no = item.serial_no; post.a_id = item.a_id; post.title = item.title; post.site_url = item.site_url; post.site_name = getSiteName(post.site_url); post.photo_url = item.photo_url; post.modified_date = item.modified_date; post.category = item.category; post.url = item.url; post.summary = item.summary; post.custom = item.custom; post.copied = item.copied; post.shared = item.shared; post.sub_category = item.sub_category; try { using (var count = db.get_shared_article_serial(item.serial_no)) { post.shares = count.First <int?>(); } } catch (Exception ex) { post.shares = -1; } post.views = "0"; finalArticleList.Add(post); } return(finalArticleList); }