Ejemplo n.º 1
0
        public StatisticsModule(IBrightstarService brightstarService, AbstractStorePermissionsProvider storePermissionsProvider)
        {
            this.RequiresBrightstarStorePermission(storePermissionsProvider, get: StorePermissions.ViewHistory);
            Get["/{storeName}/statistics"] = parameters =>
            {
                var request     = this.Bind <StatisticsRequestObject>();
                var resourceUri = "statistics" + CreateQueryString(request);

                // Set defaults
                if (!request.Latest.HasValue)
                {
                    request.Latest = DateTime.MaxValue;
                }
                if (!request.Earliest.HasValue)
                {
                    request.Earliest = DateTime.MinValue;
                }

                // Execute
                var stats = brightstarService.GetStatistics(
                    request.StoreName, request.Latest.Value, request.Earliest.Value,
                    request.Skip, DefaultPageSize + 1);

                return(Negotiate.WithPagedList(request, stats.Select(MakeResponseModel), request.Skip, DefaultPageSize,
                                               DefaultPageSize, resourceUri));
            };
        }
 public LatestStatisticsModule(IBrightstarService brightstarService, AbstractStorePermissionsProvider storePermissionsProvider)
 {
     this.RequiresBrightstarStorePermission(storePermissionsProvider, get:StorePermissions.Read);
     Get["/{storeName}/statistics/latest"] = parameters =>
         {
             var latest = brightstarService.GetStatistics(parameters["storeName"]);
             if (latest == null) return HttpStatusCode.NotFound;
             return MakeResponseModel(latest);
         };
 }
 public LatestStatisticsModule(IBrightstarService brightstarService, AbstractStorePermissionsProvider storePermissionsProvider)
 {
     this.RequiresBrightstarStorePermission(storePermissionsProvider, get: StorePermissions.Read);
     Get["/{storeName}/statistics/latest"] = parameters =>
     {
         var latest = brightstarService.GetStatistics(parameters["storeName"]);
         if (latest == null)
         {
             return(HttpStatusCode.NotFound);
         }
         return(MakeResponseModel(latest));
     };
 }
Ejemplo n.º 4
0
        public StatisticsModule(IBrightstarService brightstarService, AbstractStorePermissionsProvider storePermissionsProvider)
        {
            this.RequiresBrightstarStorePermission(storePermissionsProvider, get:StorePermissions.ViewHistory);
            Get["/{storeName}/statistics"] = parameters =>
                {
                    var request = this.Bind<StatisticsRequestObject>();
                    var resourceUri = "statistics" + CreateQueryString(request);

                    // Set defaults
                    if (!request.Latest.HasValue) {  request.Latest = DateTime.MaxValue; }
                    if (!request.Earliest.HasValue) { request.Earliest = DateTime.MinValue; }

                    // Execute
                    var stats = brightstarService.GetStatistics(
                        request.StoreName, request.Latest.Value, request.Earliest.Value,
                        request.Skip, DefaultPageSize + 1);

                    return Negotiate.WithPagedList(request, stats.Select(MakeResponseModel), request.Skip, DefaultPageSize,
                                                   DefaultPageSize, resourceUri);
                };
        }