Ejemplo n.º 1
0
        public async Task <IActionResult> DeleteElectronic(int id)
        {
            Electronic elect = await ElectronicsDb.GetElectronicAsync(_context, id);

            _context.Entry(elect).State = EntityState.Deleted;
            await _context.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Add(Electronic elect)
        {
            if (ModelState.IsValid)
            {
                elect.TimeCreated = System.DateTime.Now;
                await ElectronicsDb.AddElectronicAsync(_context, elect);

                return(RedirectToAction("Index"));
            }

            return(View());
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> Index()
        {
            List <Electronic> electronics = await ElectronicsDb.GetRecentElectronicsAsync(_context);

            using var playwright = await Playwright.CreateAsync();

            await using var browser = await playwright.Chromium.LaunchAsync();

            var page = await browser.NewPageAsync();

            await page.GotoAsync("https://www.newegg.com/d/best-sellers?cm_sp=Head_Navigation-_-Under_Search_Bar-_-Best+Sellers&icid=623089");

            var element1 = await page.QuerySelectorAsync(".item-cell");

            var element2 = await element1.QuerySelectorAsync(".item-title");

            var returned = await element2.InnerTextAsync();

            ViewBag.Message = returned;
            return(View(electronics));
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> Delete(int id)
        {
            Electronic elect = await ElectronicsDb.GetElectronicAsync(_context, id);

            return(View(elect));
        }
Ejemplo n.º 5
0
        public async Task <IActionResult> Index()
        {
            List <Electronic> electronics = await ElectronicsDb.GetElectronicsAsync(_context);

            return(View(electronics));
        }
Ejemplo n.º 6
0
        public async Task <IActionResult> Categories(string category)
        {
            List <Electronic> electronics = await ElectronicsDb.GetCategoryElectronicsAsync(_context, category);

            return(View(electronics));
        }
Ejemplo n.º 7
0
        public async Task <IActionResult> SearchResults(string search)
        {
            List <Electronic> electronics = await ElectronicsDb.GetSearchElectronicsAsync(_context, search);

            return(View(electronics));
        }