// GET: ContaUtilizador
 public ActionResult Index()
 {
     using (BdContext bd = new BdContext())
     {
         return(View(bd.ContaUtilizador.ToList()));
     }
 }
Exemplo n.º 2
0
 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;
 }
Exemplo n.º 4
0
        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;
        }
Exemplo n.º 6
0
        /// <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();
 }
Exemplo n.º 8
0
        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);
        }
Exemplo n.º 9
0
        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);
        }
Exemplo n.º 10
0
 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();
        }
Exemplo n.º 13
0
        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);
        }
Exemplo n.º 14
0
        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();
                }
            }
            //}
        }
Exemplo n.º 15
0
        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());
        }
Exemplo n.º 17
0
 public Repository(BdContext context)
 {
     _context = context;
     _dataset = _context.Set <T>();
 }
Exemplo n.º 18
0
 public UnitOfWorkProductRepo(BdContext bdContext) : base(bdContext)
 {
 }
 public OrderItemHistoryRepository(BdContext bdContext) : base(bdContext)
 {
 }
 public LancamentoHoraController(ILogger <LancamentoHoraController> logger, BdContext context)
 {
     _logger  = logger;
     _context = context;
 }
Exemplo n.º 21
0
 public TiendasController(BdContext context)
 {
     _context = context;
 }
Exemplo n.º 22
0
 public DeadRepository(BdContext bdContext)
 {
     _bdContex = bdContext;
 }
Exemplo n.º 23
0
 public VesselRepository(BdContext context) : base(context)
 {
     _dataset = context.Set <Vessel>();
 }
Exemplo n.º 24
0
 public CountryRepository(BdContext dbContext) : base(dbContext)
 {
 }
 public EquipmentRepository(BdContext context) : base(context)
 {
     _dataset = context.Set <Equipment>();
 }
Exemplo n.º 26
0
 public AppUserRepository(BdContext bdContext) : base(bdContext)
 {
 }
 public OrderHistoryRepository(BdContext context) : base(context)
 {
 }
 public UnitOfWorkOrderItemRepo(BdContext context) : base(context)
 {
 }
Exemplo n.º 29
0
 public TareasController(BdContext bdContext)
 {
     _context = bdContext;
 }
Exemplo n.º 30
0
 public GenderRepository(BdContext bdContext) : base(bdContext)
 {
 }