Example #1
0
        public void Setup()
        {
            _products = SetUpProducts();
            _tokens   = SetUpTokens();

            _dbContext = new Mock <WebApiDbContext>().Object;

            _tokenRepository   = SetUpTokenRepository();
            _productRepository = SetUpProductRepository();

            var unitOfWork = new Mock <IUnitOfWork>();

            unitOfWork.SetupGet(s => s.ProductRepository).Returns(_productRepository);
            unitOfWork.SetupGet(s => s.TokenRepository).Returns(_tokenRepository);
            _unitOfWork = unitOfWork.Object;

            _productService = new ProductService(_unitOfWork);
            _tokenService   = new TokenService(_unitOfWork);

            _client = new HttpClient {
                BaseAddress = new Uri(ServiceBaseUrl)
            };

            var tokenEntity = _tokenService.GenerateToken(1);

            _token = tokenEntity.AuthToken;

            _client.DefaultRequestHeaders.Add("Token", _token);
        }
Example #2
0
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, WebApiDbContext context)
        {
            app.UseCors();
            app.UseMvc();

            context.Database.EnsureCreated();
        }
Example #3
0
        public static void SeedHostDb(WebApiDbContext context)
        {
            context.SuppressAutoSetTenantId = true;

            // Host seed
            new InitialHostDbBuilder(context).Create();
        }
Example #4
0
 public UserService(WebApiDbContext context, UserManager <users> userManager, SignInManager <users> signInManager, RoleManager <role> roleManager, IConfiguration config)
 {
     _context       = context;
     _userManager   = userManager;
     _signInManager = signInManager;
     _roleManager   = roleManager;
     _config        = config;
 }
Example #5
0
        public void ReInitializeTest()
        {
            _dbContext       = new Mock <WebApiDbContext>().Object;
            _tokenRepository = SetUpTokenRepository();
            var unitOfWork = new Mock <IUnitOfWork>();

            unitOfWork.SetupGet(s => s.TokenRepository).Returns(_tokenRepository);
            _unitOfWork   = unitOfWork.Object;
            _tokenService = new TokenService(_unitOfWork);
        }
 public MenuController(
     IEventBus eventBus,
     ILogger <LoginController> logger,
     WebApiDbContext dbContext,
     IOptions <WebApiConfig> option)
 {
     this.eventBus     = eventBus;
     this.logger       = logger;
     this.dbContext    = dbContext;
     this.webApiConfig = option.Value;
 }
Example #7
0
        public AccountController(
            UserManager <ApplicationUser> userManager,
            SignInManager <ApplicationUser> signInManager,
            IConfiguration configuration, WebApiDbContext context)

        {
            _userManager   = userManager;
            _signInManager = signInManager;
            _configuration = configuration;
            _context       = context;
        }
Example #8
0
        public void ReInitializeTest()
        {
            _products          = SetUpProducts();
            _dbContext         = new Mock <WebApiDbContext>().Object;
            _productRepository = SetUpProductRepository();
            var unitOfWork = new Mock <IUnitOfWork>();

            unitOfWork.SetupGet(s => s.ProductRepository).Returns(_productRepository);
            _unitOfWork     = unitOfWork.Object;
            _productService = new ProductService(_unitOfWork);
        }
Example #9
0
 public LoginController(IConfiguration configuration,
                        IEventBus eventBus,
                        ILogger <LoginController> logger,
                        WebApiDbContext dbContext,
                        IOptions <WebApiConfig> option)
 {
     this.configuration    = configuration;
     this.connectionString = configuration["WebApiConfig:SqlConnectionString"];
     this.eventBus         = eventBus;
     this.logger           = logger;
     this.dbContext        = dbContext;
     this.webApiConfig     = option.Value;
 }
Example #10
0
        protected BaseController(WebApiDbContext db)
        {
            this.Db = db;

            if (Db.TodoItems.Count() == 0)
            {
                // Create a new TodoItem if collection is empty,
                // which means you can't delete all TodoItems.
                Db.TodoItems.Add(new TodoItem {
                    Name = "Item1"
                });
                Db.SaveChanges();
            }
        }
Example #11
0
        public static void SeedHostDb(WebApiDbContext context)
        {
            context.SuppressAutoSetTenantId = true;

            // Host seed
            new InitialHostDbBuilder(context).Create();

            // Default tenant seed (in host database).
            new DefaultTenantBuilder(context).Create();
            new TenantRoleAndUserBuilder(context, 1).Create();

            // Default blogs seed (in host database).
            new DefaultBlogsBuilder(context).Create();
        }
Example #12
0
        public static void Initialize(IServiceProvider serviceProvider)
        {
            using (var context = new WebApiDbContext(
                       serviceProvider.GetRequiredService <DbContextOptions <WebApiDbContext> >()))
            {
                // Look for any stations
                if (context.Stations.Any())
                {
                    Console.WriteLine("FOUND SOME");
                    return;   // Data was already seeded
                }

                Console.WriteLine($"READING FROM STATIONS");
                List <NOAAStation> stationList = NOAAStationHelper.GetNOAAStationsList();

                Console.WriteLine($"FINDING DUPLICATES");
                // as it turns out, there are duplicates in the data
                var duplicates = stationList.GroupBy(s => s.ICAO)
                                 .Where(grp => grp.Count() > 1)
                                 .Select(grp => grp.Key);

                Console.WriteLine($"{duplicates.Count()} DUPLICATES FOUND");

                //find the duplicate ICAO values
                //store one
                //remove all
                //re-insert the one
                Console.WriteLine($"REMOVING DUPLICATES");
                foreach (var item in duplicates)
                {
                    NOAAStation m = stationList.First(s => s.ICAO == item);
                    stationList.RemoveAll(s => s.ICAO == item);
                    stationList.Add(m);
                }

                //WRITE TO DB
                try{
                    context.Stations.AddRange(stationList);
                    context.SaveChanges();
                    Console.WriteLine($"LOADING COMPLETE: {context.Stations.Count()}");
                }
                catch (Exception exp) {
                    Console.WriteLine(exp.Message);
                }
            }
        }
Example #13
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                app.UseHsts();
            }

            using (var apiContext = new WebApiDbContext())
            {
                apiContext.Database.Migrate();
            }
            app.UseHttpsRedirection();
            app.UseMvc();
        }
Example #14
0
 public OrderService(WebApiDbContext context, IHttpContextAccessor httpContextAccessor)
 {
     _context             = context;
     _httpContextAccessor = httpContextAccessor;
 }
 public UnitOfWork()
 {
     _context = new WebApiDbContext();
 }
Example #16
0
 public MovimientoCajaController(WebApiDbContext context)
 {
     _context = context;
 }
Example #17
0
 public LanguageService(WebApiDbContext context,
                        IConfiguration config)
 {
     _config  = config;
     _context = context;
 }
Example #18
0
 public Genre(IConfiguration configuration)
 {
     context = new WebApiDbContext(configuration);
 }
 public AnimalInfoRepository(WebApiDbContext context)
 {
     _context = context;
 }
Example #20
0
 public AdminController(WebApiDbContext context, IMapper mapper, IUserService userService)
 {
     _context     = context;
     _mapper      = mapper;
     _userService = userService;
 }
 public OrderRepository(WebApiDbContext context) : base(context)
 {
     this._WebApiDbContext = context;
 }
Example #22
0
 public PedidoController(WebApiDbContext context)
 {
     _context = context;
 }
Example #23
0
 public VendedorController(WebApiDbContext context, IAlmacenadorDeArchivos _almacenadorDeArchivos)
 {
     _context = context;
     almacenadorDeArchivos = _almacenadorDeArchivos;
 }
        public static void Initialize(IServiceProvider serviceProvider)
        {
            using (var _context = new WebApiDbContext(serviceProvider.GetRequiredService <DbContextOptions <WebApiDbContext> >()))
            {
                // Agregando Artistas a la BD
                if (_context.Artistas.Any())
                {
                    return;
                }

                _context.Artistas.AddRange(
                    new Artista {
                    Nombre = "Luis Miguel"
                },
                    new Artista {
                    Nombre = "Ricardo Arjona"
                },
                    new Artista {
                    Nombre = "Kalimba"
                }
                    );

                _context.SaveChanges();


                // Agregando Albumes a la BD
                if (_context.Albumes.Any())
                {
                    return;
                }

                _context.Albumes.AddRange(
                    new Album
                {
                    ArtistaID = _context.Artistas.FirstOrDefault(a => a.Nombre.Equals("Kalimba")).ArtistaID,
                    Titulo    = $"Mi Otro Yo",
                    Precio    = 200,
                    Anio      = 2008
                },

                    new Album
                {
                    ArtistaID = _context.Artistas.FirstOrDefault(a => a.Nombre.Equals("Kalimba")).ArtistaID,
                    Titulo    = $"Aerosoul",
                    Precio    = 275,
                    Anio      = 2004
                },

                    new Album
                {
                    ArtistaID = _context.Artistas.FirstOrDefault(a => a.Nombre.Equals("Ricardo Arjona")).ArtistaID,
                    Titulo    = $"Circo Soledad",
                    Precio    = 180,
                    Anio      = 2017
                },

                    new Album
                {
                    ArtistaID = _context.Artistas.FirstOrDefault(a => a.Nombre.Equals("Luis Miguel")).ArtistaID,
                    Titulo    = $"Romance",
                    Precio    = 290,
                    Anio      = 1991
                }
                    );

                _context.SaveChanges();
            }
        }
 public EFRepository(WebApiDbContext apiContext)
 {
     context = apiContext;
 }
Example #26
0
 public RepositoryBase(WebApiDbContext context)
 {
     this.Context = context;
 }
Example #27
0
 public GetNewsWithPositivityHandler(WebApiDbContext dbContext)
 {
     _dbContext = dbContext;
 }
Example #28
0
 public ApplicationUserController(WebApiDbContext db)
 {
     this.db = db;
 }
Example #29
0
 public DepositoController(WebApiDbContext context)
 {
     _context = context;
 }
Example #30
0
 public SizeService(WebApiDbContext context)
 {
     _context = context;
 }