Ejemplo n.º 1
0
        public VendaController(ISieveProcessor sieveProcessor, LojaDiscosDbContext context, IMapper mapper)
        {
            _context        = context;
            _sieveProcessor = sieveProcessor;
            _mapper         = mapper;

/*
 *          Venda v = new Venda()
 *          {
 *              Id_Cliente = 1,
 *              Vl_Total = 100,
 *              Vl_TotalCashback = 23,
 *              Produtos = { new ItemVenda() { Id_Disco = 14, Preco = 177, Cashback = 7 }, new ItemVenda() { Id_Disco = 7, Preco = 143, Cashback = 2 } }
 *          };
 *          _context.Vendas.Add(v);
 *          _context.SaveChanges();
 *
 *          if (_context.Vendas.Count() == 0)
 *          {
 *              for (int i = 0; i < 200; i++)
 *              {
 *                  _context.Vendas.Add(new Venda());
 *              }
 *
 *              _context.SaveChanges();
 *          }
 */
        }
Ejemplo n.º 2
0
        public DiscoController(ISieveProcessor sieveProcessor, LojaDiscosDbContext context, IDadosExternosClient dadosExternosClient)
        {
            _context             = context;
            _sieveProcessor      = sieveProcessor;
            _dadosExternosClient = dadosExternosClient;

            if (_context.Discos.Count() == 0)
            {
                try
                {
                    GetDadosExternos("pop").Wait();
                    GetDadosExternos("mpb").Wait();
                    GetDadosExternos("classic").Wait();
                    GetDadosExternos("rock").Wait();
                }
                catch (Exception)
                {
                    Debug.WriteLine("Erro ao popular dados do Last-FM. Verifique se a API Key está correta.");
                }
            }
        }