Example #1
0
        public IHttpActionResult Get(string id)
        {
            ChartHelperForRest helper = null;

            try
            {
                helper = new ChartHelperForRest(Map);
                return(Ok(helper.GetChartData(id, System.Web.HttpContext.Current.Server.UrlDecode(System.Web.HttpContext.Current.Request.QueryString.ToString()))));
            }
            catch (ChartIdIsMissingException chartIdIsMissingException)
            {
                return(ResponseMessage(Request.CreateResponse(HttpStatusCode.NotFound, chartIdIsMissingException.Message)));
            }
            catch (ChartHandledException chartHandledException)
            {
                int?dashboardId = Database.GetDashboardPK(Convert.ToInt32(id));
                if (!dashboardId.HasValue)
                {
                    return(ResponseMessage(Request.CreateResponse(HttpStatusCode.NotFound, chartHandledException.Message)));
                }

                try
                {
                    return(Ok(helper.GetChartJsonObjectWithException(dashboardId.Value, Convert.ToInt32(id), chartHandledException)));
                }
                catch (Exception exception)
                {
                    throw new BackAndApiUnexpectedResponseException(exception, this);
                }
            }
            catch (Exception exception)
            {
                throw new BackAndApiUnexpectedResponseException(exception, this);
            }
        }
Example #2
0
        public ActionResult Get(string pk, string parameters)
        {
            ChartHelperForRest helper = null;

            try
            {
                helper = new ChartHelperForRest(Map);
                return(Json(helper.GetChartData(pk, parameters)));
            }
            catch (ChartIdIsMissingException)
            {
                return(new ChartNotFoundApiHttpException(pk, Response));
            }
            catch (ChartHandledException exception)
            {
                int?dashboardId = Database.GetDashboardPK(Convert.ToInt32(pk));
                if (!dashboardId.HasValue)
                {
                    return(new ChartNotFoundApiHttpException(pk, Response));
                }

                try
                {
                    return(Json(helper.GetChartJsonObjectWithException(dashboardId.Value, Convert.ToInt32(pk), exception)));
                }
                catch (Exception e)
                {
                    return(UnexpectedException(e, Response));
                }
            }
            catch (Exception exception)
            {
                return(UnexpectedException(exception, Response));
            }
        }