Example #1
0
 public HttpResponseMessage Get(int?top, int?id, int?authorid, int?subjectid)
 {
     using (ElectronicsEntities ee = new ElectronicsEntities())
     {
         var ee_articles = ee.GetArticles(id, null, null, null, authorid, subjectid, top).ToList();
         var articles    = new List <object>();
         foreach (var article in ee_articles)
         {
             articles.Add(new
             {
                 ID               = article.ID,
                 CreationTime     = article.CreationTime,
                 Description      = article.Description,
                 FilePath         = article.FilePath,
                 MainText         = article.MainText,
                 ModificationTime = article.ModificationTime,
                 Title            = article.Title,
                 Authors          = ee.GetArticlesAuthors(article.ID, null).ToList().Select(aa => aa.AuthorID).ToList(),
                 Subjects         = ee.GetArticlesSubjects(article.ID, null).ToList().Select(aa => aa.SubjectID).ToList(),
                 IsImageOnly      = article.IsImageOnly,
                 IsTextOnly       = article.IsTextOnly
             });
         }
         return(Globals.FinishResponse(articles));
     }
 }
Example #2
0
        public HttpResponseMessage Get(string q)
        {
            using (ElectronicsEntities ee = new ElectronicsEntities())
            {
                var ee_subjects  = ee.GetSubjects(null, null, q).ToList();
                var ee_articlesT = ee.GetArticles(null, q, null, null, null, null, null);
                var ee_articlesD = ee.GetArticles(null, null, q, null, null, null, null);
                var ee_articlesM = ee.GetArticles(null, null, null, q, null, null, null);

                var joined = ee_subjects.Select(s => new { Title = s.Name, ID = s.ID, Type = "S" }).ToList();
                joined.AddRange(ee_articlesT.Select(a => new { Title = a.Title, ID = a.ID, Type = "A" }).ToList());
                joined.AddRange(ee_articlesD.Select(a => new { Title = a.Title, ID = a.ID, Type = "A" }).ToList());
                joined.AddRange(ee_articlesM.Select(a => new { Title = a.Title, ID = a.ID, Type = "A" }).ToList());

                return(Globals.FinishResponse(joined));
            }
        }
Example #3
0
        public HttpResponseMessage Get()
        {
            using (ElectronicsEntities ee = new ElectronicsEntities())
            {
                var ee_subjects = ee.GetSubjects(null, null, null);
                List <SubjectResponse> subjects = new List <SubjectResponse>();
                foreach (var s in ee_subjects)
                {
                    var ee_articles = ee.GetArticles(null, null, null, null, null, s.ID, null).ToList();
                    subjects.Add(new SubjectResponse
                    {
                        ID       = s.ID,
                        ParentID = s.ParentID,
                        Name     = s.Name,
                        Articles = ee_articles.Select(a => new { ID = a.ID, Title = a.Title, URL = a.FilePath })
                    });
                }

                return(Globals.FinishResponse(subjects));
            }
        }