Exemple #1
0
        public static void SeedData(this IApplicationBuilder app)
        {
            using (var serviceScope = app.ApplicationServices.GetRequiredService <IServiceScopeFactory>().CreateScope())
            {
                EmprestimosJogosContext _context = serviceScope.ServiceProvider.GetService <EmprestimosJogosContext>();

                Usuario _usuario = GetUsuario();

                if (!_context.Usuario.Any(wh => wh.Id == _usuario.Id))
                {
                    _context.Usuario.Add(_usuario);
                }

                Jogo _jogo = GetJogo();

                if (!_context.Jogo.Any(wh => wh.Id == _jogo.Id))
                {
                    _context.Jogo.Add(_jogo);
                }

                Amigo _amigo = GetAmigo();

                if (!_context.Amigo.Any(wh => wh.Id == _amigo.Id))
                {
                    _context.Amigo.Add(_amigo);
                }

                try
                {
                    _context.SaveChanges();
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
 public UsuarioRepository(EmprestimosJogosContext context)
     : base(context)
 {
 }
Exemple #3
0
 public PerfilRepository(EmprestimosJogosContext context)
     : base(context)
 {
 }
 public TokenTypeRepository(EmprestimosJogosContext context)
     : base(context)
 {
 }
 public UsuarioStore(EmprestimosJogosContext context,
                     IUsuarioRepository repository)
 {
     _context    = context;
     _repository = repository;
 }
 public PerfilStore(EmprestimosJogosContext context,
                    IPerfilRepository repository)
 {
     _context    = context;
     _repository = repository;
 }
 public UnitOfWork(EmprestimosJogosContext context)
 {
     _context = context;
 }
Exemple #8
0
 public AmigoRepository(EmprestimosJogosContext context)
     : base(context)
 {
 }
 public Repository(EmprestimosJogosContext context)
 {
     _context = context;
 }