public GenreController()
 {
     string cnnString = ConfigurationManager.ConnectionStrings["defaultCnn"].ToString();
     var dbContext = new CinemaDbContext(cnnString);
     var genreRepo = new GenreRepository(dbContext);
     _genreService = new GenreService(genreRepo);
 }
 public override void OnAuthorization(AuthorizationContext filterContext)
 {
     var username = filterContext.HttpContext.User.Identity.Name;
     string cnnString = ConfigurationManager.ConnectionStrings["defaultCnn"].ToString();
     var dbContext = new CinemaDbContext(cnnString);
     var userRepo = new UserRepository(dbContext);
     UserService service = new UserService(userRepo);
     bool isAdmin = service.IsAdmin(username);
     if (!isAdmin)
         throw new UnauthorizedAccessException();
 }
示例#3
0
 public BaseController()
 {
     string cnnString = ConfigurationManager.ConnectionStrings["DefaultConnection"].ToString();
     var dbContext = new CinemaDbContext(cnnString);
     var actorsRepo = new ActorRepository(dbContext);
     _actorService = new ActorService(actorsRepo);
     var genreRepo = new GenreRepository(dbContext);
     _genreService = new GenreService(genreRepo);
     var hallRepo = new HallRepository(dbContext);
     _hallService = new HallService(hallRepo);
     var movieRepo = new MovieRepository(dbContext);
     _movieService = new MovieService(movieRepo, actorsRepo);
 }