Exemplo n.º 1
0
        public async Task <IActionResult> GetImgs([FromBody] QueryVm entity)
        {
            var imgsList = await _mongodbHelper.GetImagesDataAsync();

            var totalCount = imgsList.Count;

            return(Json(new
            {
                data = imgsList.OrderByDescending(o => o.Level).Skip((entity.current - 1) * entity.pageSize).Take(entity.pageSize),
                total = totalCount
            }));
        }
Exemplo n.º 2
0
        //Gets Works matching a query
        public QueryVm Search(QueryVm query)
        {
            IQueryable <Work> results   = Enumerable.Empty <Work>().AsQueryable();
            QueryVm           returnObj = new QueryVm();

            //List<Work> workList = db.Works.Where(w => w.Type.ToLower().Contains(query.Query)).ToList();


            if (query.SearchBy == "title")
            {
                results = (from w in db.Works
                           where w.Type == query.SearchFor &&
                           w.Title.ToLower().Contains(query.Query.ToLower())
                           select w).Include(w => w.Authors);
            }
            else if (query.SearchBy == "author")
            {
                results = (from w in db.Works
                           where w.Type == query.SearchFor &&
                           w.ExternalAuthor.ToLower().Contains(query.Query.ToLower())
                           select w).Include(w => w.Authors);
            }
            else if (query.SearchBy == "genre")
            {
                results = (from w in db.Works
                           where w.Type == query.SearchFor &&
                           w.Genres.ToLower().Contains(query.Query.ToLower())
                           select w).Include(w => w.Authors);
            }
            else if (query.SearchBy == "tag")
            {
                results = (from w in db.Works
                           where w.Type == query.SearchFor &&
                           w.Tags.ToLower().Contains(query.Query.ToLower())
                           select w).Include(w => w.Authors);
            }

            returnObj.Results = results.ToList();
            return(returnObj);
        }
 public IHttpActionResult Post(QueryVm query)
 {
     return(Ok(repo.Search(query)));
 }