Esempio n. 1
0
        private async Task GetMovieGenres(Movie movie)
        {
            var relationRepository = new RelationRepository(Configuration, MemoryCache);

            var isExist = MemoryCache.TryGetValue("CACHEMOVIERELATIONS" + movie.GetId(), out List <Relation> movieRelations);

            if (!isExist)
            {
                movieRelations = await relationRepository.GetRelationsByParent(
                    movie.GetEntityCategoryId(), movie.GetId());

                MemoryCache.Set("CACHEMOVIERELATIONS" + movie.GetId(), movieRelations);
                TrakkerCache.SaveCacheEntry("CACHEMOVIERELATIONS" + movie.GetId());
            }

            var movieGenreRepository = new MovieGenreRepository(Configuration, MemoryCache);

            foreach (var relation in movieRelations)
            {
                if (relation.CategoryTo == MovieGenre.ENTITY_CATEGORY_ID)
                {
                    movie.AddGenre(await movieGenreRepository.GetById(relation.EntityTo));
                }
            }
        }
Esempio n. 2
0
        public override async Task <Movie> GetById(long id)
        {
            var isExist = MemoryCache.TryGetValue("CACHEMOVIE" + id, out Movie movie);

            if (!isExist)
            {
                movie = await GetSingleByDesiredParameter(ID_FIELD_NAME, id);

                MemoryCache.Set("CACHEMOVIE" + id, movie);
                TrakkerCache.SaveCacheEntry("CACHEMOVIE" + id);
            }
            return(movie);
        }
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, IMemoryCache cache)
        {
            //Need to initialize the list of cache
            TrakkerCache.InitializeCacheList();

//            Console.WriteLine(Configuration.GetConnectionString("DefaultConnection"));
//            string cs = Configuration["ConnectionStrings:DefaultConnection"];

            var loadDataTask = StartUpTasks.TasksOnStartUp(Configuration, cache);

            loadDataTask.Wait();

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            var supportedCultures = new List <CultureInfo>
            {
                new CultureInfo("en-GB"),
                new CultureInfo("en-US"),
                new CultureInfo("en"),
                new CultureInfo("fr-FR"),
                new CultureInfo("fr"),
                new CultureInfo("ml-IN"),
                new CultureInfo("hi-IN")
            };

            var options = new RequestLocalizationOptions
            {
                DefaultRequestCulture = new RequestCulture("en-US"),
                SupportedCultures     = supportedCultures,
                SupportedUICultures   = supportedCultures,
            };

            app.UseRequestLocalization(options);

            loggerFactory.AddDebug();

            app.UseCors("SiteCorsPolicy");

            app.UseAuthentication();
            app.UseMvc();
        }
 public ActionResult Get()
 {
     TrakkerCache.ClearCache(_memoryCache);
     return(Json("Hello"));
 }