// GET: ContaUtilizador public ActionResult Index() { using (BdContext bd = new BdContext()) { return(View(bd.ContaUtilizador.ToList())); } }
public PersonAggregate(IAliveRepository aliveRepository, IDeadRepository deadRepository, BdContext bdContext) { _aliveRepository = aliveRepository; _deadRepository = deadRepository; _bdContext = bdContext; }
public PricesController(BdContext context, IMapper mapper, IPricesRepository pricesRepository, IUnitOfWork <Prices> unitOfWork) { _mapper = mapper; _pricesRepository = pricesRepository; _unitOfWorkPrices = unitOfWork; _context = context; }
public void TestInit() { _bdContext = BdContextBuilder.CreateInMemoryContext(Guid.NewGuid().ToString()); _aliveRepository = new AliveRepository(_bdContext); _deadRepository = new DeadRepository(_bdContext); _personAggregate = new PersonAggregate(_aliveRepository, _deadRepository, _bdContext); }
public OrderItemHistoriesController(BdContext context, IMapper mapper, IOrderItemHistoryRepository orderItemRepository /*, IUnitOfWork<OrderItemHistory> unitOfWork*/) { _mapper = mapper; _orderItemHistoryRepository = orderItemRepository; //_unitOfWorkOrderItem = unitOfWork; _context = context; }
/// <summary> /// Patron de diseño Singleton, que solo crea una clase de bd si no existe otra /// </summary> /// <returns>Retorna un objeto abstracto de la bd</returns> public BdContext ConectarBD() { if (database == null) { database = new BdContext(); } return(database); }
public ProductsController(BdContext context, IProductRepository productRepository, IUnitOfWork <Product> unitOfWorkProduct, IMapper mapper) { _context = context; _productRepository = productRepository; _unitOfWorkProduct = unitOfWorkProduct; _mapper = mapper; _cancellationToken = new CancellationToken(); }
public void CreateDbWithDuplicateContraint() { var options = new DbContextOptionsBuilder <BdContext>().UseInMemoryDatabase(Guid.NewGuid().ToString()).Options; var context = new BdContext(options); context.AddRange(TestUtils.LoadDb <Alive>(@"DbMocks/DuplicatedDocuments.json")); context.SaveChanges(); //Db inicia já com documento duplicado. context.Alive.Count(a => a.Document == 12345).Should().Be(2); }
public static BdContext CreateInMemoryContext(string dbName) { var options = new DbContextOptionsBuilder <BdContext>().UseInMemoryDatabase(databaseName: dbName).Options; var context = new BdContext(options); context.AddRange(TestUtils.LoadDb <Alive>(@"DbMocks/DuplicatedDocuments.json")); context.SaveChanges(); return(context); }
public AppUsersController(IHttpContextAccessor httpContextAccessor, BdContext context, IAppUserRepository appUserRepository, IUnitOfWork <AppUser> unitOfWorkAppUser, IMapper mapper) : base(httpContextAccessor) { _appUserRepository = appUserRepository; _unitOfWorkAppUser = unitOfWorkAppUser; _cancellationToken = new CancellationToken(); _httpContextAccessor = httpContextAccessor; _mapper = mapper; _context = context; }
public ActionResult Registo(Utilizador utilizador) { if (ModelState.IsValid) { using (BdContext bd = new BdContext()) { bd.ContaUtilizador.Add(utilizador); bd.SaveChanges(); } ModelState.Clear(); return(RedirectToAction("Login")); } return(View()); }
public OrderHistoriesController(BdContext context, IOrderHistoryRepository orderHistoryRepository, IUnitOfWork <OrderHistory> unitOfWork, IHttpContextAccessor httpContextAccessor, IMapper mapper) : base(httpContextAccessor) { _orderHistoryRepository = orderHistoryRepository; _unitOfWorkOrderhistory = unitOfWork; _mapper = mapper; _httpContextAccessor = httpContextAccessor; _context = context; _cancellationToken = new CancellationToken(); }
public static BdContext CreateSqliteContext(string dbName) { var connection = new SqliteConnection("DataSource=:memory:"); connection.Open(); var options = new DbContextOptionsBuilder <BdContext>().UseSqlite(connection).Options; var context = new BdContext(options); context.Database.EnsureCreated(); context.AddRange(TestUtils.LoadDb <Alive>(@"DbMocks/Alive.json")); context.SaveChanges(); return(context); }
static void Main(string[] args) { using (var context = new BdContext("flibusta_online_fb2Entities")) { context.Autors.Load(); } return; for (int i = 0; i < threadCount; i++) { manualEvents[i] = new ManualResetEvent(false); } using (libraryEntities context = new libraryEntities()) { var tmp = context.libavtornames.OrderBy(x => x.AvtorId).ToList(); int counter = 0; long allCount = context.libavtornames.Count(); while (counter < allCount) { for (int i = 0; i < threadCount; i++) { manualEvents[i].Reset(); new Thread(AddAvtors).Start(new MyStruct() { Avtor = tmp.Skip(counter).Take(entiresCount).ToList(), Event = manualEvents[i] }); counter += entiresCount; //Thread.Sleep(1000); } WaitHandle.WaitAll(manualEvents); Console.WriteLine(counter); } using (BdContext cont = new BdContext("ConnectionStringName")) { foreach (var autor in listAutor) { cont.Autors.Add(autor); } cont.SaveChanges(); } } //} }
public void CreateDbWithConstraintViolationTest() { var connection = new SqliteConnection("DataSource=:memory:"); connection.Open(); var options = new DbContextOptionsBuilder <BdContext>().UseSqlite(connection).Options; using (var context = new BdContext(options)) { context.Database.EnsureCreated(); context.AddRange(TestUtils.LoadDb <Alive>(@"DbMocks/DuplicatedDocuments.json")); Action saveContext = () => context.SaveChanges(); saveContext.Should().Throw <DbUpdateException>() .WithInnerException <SqliteException>(); } }
public ActionResult Login(Utilizador user) { using (BdContext bd = new BdContext()) { var usr = bd.ContaUtilizador.Single(u => u.Username == user.Username && u.Password == user.Password); if (usr != null) { Session["UtilizadorId"] = user.UtilizadorId.ToString(); Session["Username"] = user.Username.ToString(); return(RedirectToAction("Index", "Home")); } else { ModelState.AddModelError("", "Username ou a password estão mal"); } } return(View()); }
public Repository(BdContext context) { _context = context; _dataset = _context.Set <T>(); }
public UnitOfWorkProductRepo(BdContext bdContext) : base(bdContext) { }
public OrderItemHistoryRepository(BdContext bdContext) : base(bdContext) { }
public LancamentoHoraController(ILogger <LancamentoHoraController> logger, BdContext context) { _logger = logger; _context = context; }
public TiendasController(BdContext context) { _context = context; }
public DeadRepository(BdContext bdContext) { _bdContex = bdContext; }
public VesselRepository(BdContext context) : base(context) { _dataset = context.Set <Vessel>(); }
public CountryRepository(BdContext dbContext) : base(dbContext) { }
public EquipmentRepository(BdContext context) : base(context) { _dataset = context.Set <Equipment>(); }
public AppUserRepository(BdContext bdContext) : base(bdContext) { }
public OrderHistoryRepository(BdContext context) : base(context) { }
public UnitOfWorkOrderItemRepo(BdContext context) : base(context) { }
public TareasController(BdContext bdContext) { _context = bdContext; }
public GenderRepository(BdContext bdContext) : base(bdContext) { }