Example #1
0
        /// <summary>
        /// Get list of Tutorials
        /// </summary>
        /// <returns>json list of Tutorial view models</returns>
        public IHttpActionResult GetList()
        {
            try
            {
                // get list
                List <TutorialViewModel> tutorials;

                log.Debug("_tutorialService.GetTutorials");

                // add edit url
                tutorials = _tutorialService.GetTutorials()
                            .Select(tutorial => new TutorialViewModel(tutorial, GetEditUrl(tutorial.TutorialId)))
                            .ToList();

                log.Debug("result: 'success', count: " + (tutorials != null ? tutorials.Count().ToString() : "null"));

                //return Json(tutorials, JsonRequestBehavior.AllowGet);
                //return Content(JsonConvert.SerializeObject(tutorials), "application/json");
                //return JsonConvert.SerializeObject(tutorials);
                return(Ok(tutorials));
            }
            catch (Exception e)
            {
                // error
                log.Error(e.ToString());

                throw;
            }
        }