Exemplo n.º 1
0
        public HttpResponseMessage Get(string type)
        {
            try
            {
                switch (type.ToLower())
                {
                case "pagevisits":
                    var pages = _statsRepository.FetchPageVisits().Select(pv => new PageVisit(pv).GetJSON());
                    return(Request.CreateResponse(HttpStatusCode.OK, pages));

                case "clicks":
                    var visits = StatisticsService.GetPageVisitAggregation(_statsRepository);
                    return(Request.CreateResponse(HttpStatusCode.OK, visits));

                case "browsers":
                    var browsers = StatisticsService.GetBrowserStats();
                    return(Request.CreateResponse(HttpStatusCode.OK, browsers));

                default:
                    throw new ArgumentException("Requestion Type Not Found:" + type);
                }
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex));
            }
        }