Ejemplo n.º 1
0
        public static void Initialize(IServiceProvider serviceProvider)
        {
            using (var context = new LearningCoreContext(
                       serviceProvider.GetRequiredService <
                           DbContextOptions <LearningCoreContext> >()))
            {
                var jsondata = FileHelper.ReadFile($"{AppContext.BaseDirectory}Files\\InitializeData.json");

                if (context.MxAttributes.Any())
                {
                    return;   // DB has been seeded
                }
                if (jsondata.IsNullOrWhiteSpace())
                {
                    return;
                }
                var result = JsonSerializer.Deserialize <InitializeData_Json>(jsondata);//, typeof(InitializeData_Json)
                context.MxAttributes.AddRange(
                    result.mx_Attributes
                    );
                context.Movie.AddRange(
                    result.movies
                    );
                context.SaveChanges();
            }
        }
Ejemplo n.º 2
0
        public SampleController(IConfiguration config
                                , ILogger <SampleController> logger
                                , LearningCoreContext context)
        {
            _fileSizeLimit = config.GetValue <long>("FileSizeLimit");

            // To save physical files to a path provided by configuration:
            _targetFilePath = config.GetValue <string>("StoredFilesPath");
            _logger         = logger;
            _context        = context;
        }
        public void GetTodoItemsTest()
        {
            using (var _context = new LearningCoreContext())
            {
                var logger   = new Mock <ILogger <TodoItemsController> >();
                var controll = new TodoItemsController(_context, logger.Object);

                var result = controll.GetTodoItems();

                Assert.IsTrue(result.Result.Value.Count() > 0);
            }
        }
 public ProductsController(LearningCoreContext context)
 {
     _context = context;
 }
 public MoviesController(LearningCoreContext context)
 {
     _context = context;
 }
Ejemplo n.º 6
0
 public FilesService(LearningCoreContext context)
 {
     _context = context;
 }
 public TodoItemsController(LearningCoreContext context
                            , ILogger <TodoItemsController> logger)
 {
     _context = context;
     _logger  = logger;
 }
 public AttributesController(ILogger <AttributesController> logger
                             , LearningCoreContext context)
 {
     _logger  = logger;
     _context = context;
 }