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); }
public void Configure(IApplicationBuilder app, IHostingEnvironment env, WebApiDbContext context) { app.UseCors(); app.UseMvc(); context.Database.EnsureCreated(); }
public static void SeedHostDb(WebApiDbContext context) { context.SuppressAutoSetTenantId = true; // Host seed new InitialHostDbBuilder(context).Create(); }
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; }
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; }
public AccountController( UserManager <ApplicationUser> userManager, SignInManager <ApplicationUser> signInManager, IConfiguration configuration, WebApiDbContext context) { _userManager = userManager; _signInManager = signInManager; _configuration = configuration; _context = context; }
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); }
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; }
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(); } }
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(); }
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); } } }
// 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(); }
public OrderService(WebApiDbContext context, IHttpContextAccessor httpContextAccessor) { _context = context; _httpContextAccessor = httpContextAccessor; }
public UnitOfWork() { _context = new WebApiDbContext(); }
public MovimientoCajaController(WebApiDbContext context) { _context = context; }
public LanguageService(WebApiDbContext context, IConfiguration config) { _config = config; _context = context; }
public Genre(IConfiguration configuration) { context = new WebApiDbContext(configuration); }
public AnimalInfoRepository(WebApiDbContext context) { _context = context; }
public AdminController(WebApiDbContext context, IMapper mapper, IUserService userService) { _context = context; _mapper = mapper; _userService = userService; }
public OrderRepository(WebApiDbContext context) : base(context) { this._WebApiDbContext = context; }
public PedidoController(WebApiDbContext context) { _context = context; }
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; }
public RepositoryBase(WebApiDbContext context) { this.Context = context; }
public GetNewsWithPositivityHandler(WebApiDbContext dbContext) { _dbContext = dbContext; }
public ApplicationUserController(WebApiDbContext db) { this.db = db; }
public DepositoController(WebApiDbContext context) { _context = context; }
public SizeService(WebApiDbContext context) { _context = context; }