コード例 #1
0
ファイル: DefinitionController.cs プロジェクト: qqga/cshh
 public ActionResult Get(int wordId)
 {
     try
     {
         IEnumerable <WordDefinition> wordDefinitions = _wordDefinitionService.GetWordDefinitions(wordId);
         return(Json(wordDefinitions.Select(_ => new { _.Definition, _.Example }), JsonRequestBehavior.AllowGet));
     }
     catch (Exception ex)
     {
         return(new HttpStatusCodeResult(HttpStatusCode.BadRequest, ex.CollectMessages()));
     }
 }
コード例 #2
0
        public ActionResult JqGridList(JqGridRequest jqGridRequest, int word_Id)
        {
            try
            {
                var translates = _wordDefinitionService.GetWordDefinitions(word_Id);

                var resp = new JqGridResponse <WordDefinition, WordDefinitionViewModel>
                               (jqGridRequest, translates.AsQueryable(), d => d.Id, Newtonsoft.Json.JsonConvert.DeserializeObject, d => /*new WordDefinitionViewModel(d)*/ _Mapper.Map <WordDefinitionViewModel>(d));

                resp.rows.Count();//invoke query to detect errrors before procees actionResult

                return(Json(resp, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest, ex.CollectMessages()));
            }
        }