Example #1
0
        /// <summary>
        /// Get CalendarEvent by id
        /// </summary>
        /// <param name="id">CalendarEvent id</param>
        /// <returns>CalendarEvent json view model</returns>
        public IHttpActionResult Get(int id)
        {
            try
            {
                // get
                log.Debug("_calendarEventService.GetCalendarEvent - calendarEventId: " + id + " ");

                var calendarEvent = new CalendarEventViewModel(_calendarEventService.GetCalendarEvent(id));

                log.Debug("_calendarEventService.GetCalendarEvent - " + CalendarEventViewModel.FormatCalendarEventViewModel(calendarEvent));

                log.Debug("result: 'success'");

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

                throw;
            }
        }