Exemplo n.º 1
0
        public HttpResponseMessage AmountOfMaintenanceBookings(int week)
        {
            var context        = new TimeTableContext(WebConfigurationManager.AppSettings["DbConnectionString"]);
            var userRepository = new UserRepository(context);
            var userService    = new UserService(userRepository);

            var user = userService.GetUserById(UserId);

            if (user.Role != TimeTableRole.Management && user.Role != TimeTableRole.Admin && user.Role != TimeTableRole.Fit)
            {
                return(Request.CreateResponse(HttpStatusCode.Unauthorized, "Insufficient permissions."));
            }

            var repository = new BookingRepository(context);
            var service    = new StatisticsService();

            var amount = service.AmountOfMaintenanceBookings(repository, week);

            return(Request.CreateResponse(HttpStatusCode.OK, amount));
        }