コード例 #1
0
        public async Task <ActionResult> Results(string q)
        {
            Tuple <List <NoticeBoardViewModel>, List <NoticeViewModel> > results = new Tuple <List <NoticeBoardViewModel>, List <NoticeViewModel> >(
                new List <NoticeBoardViewModel>(),
                new List <NoticeViewModel>()
                );

            using (NoticeBoardManager m = new NoticeBoardManager())
            {
                var boards = await m.SearchAsync(q);

                foreach (var i in boards)
                {
                    results.Item1.Add(NoticeBoardMappings.To <NoticeBoardViewModel>(i));
                }
            }

            using (NoticeManager m = new NoticeManager())
            {
                var notices = await m.SearchAsync(q);

                foreach (var i in notices)
                {
                    results.Item2.Add(NoticeMappings.To <NoticeViewModel>(i));
                }
            }

            return(View(results));
        }
コード例 #2
0
        public async Task <JsonResult> Notices(string q)
        {
            using (NoticeManager m = new NoticeManager())
            {
                var boards = await m.SearchAsync(q);

                var result = new List <SearchItemJVM>();
                foreach (var i in boards)
                {
                    result.Add(new SearchItemJVM {
                        value = i.Title, tokens = i.Title.Split(' ', ',', '.')
                    });
                }

                return(Json(result, JsonRequestBehavior.AllowGet));
            }
        }