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")); }
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()); }
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)); }
public async Task <IActionResult> Delete(int id) { Electronic elect = await ElectronicsDb.GetElectronicAsync(_context, id); return(View(elect)); }
public async Task <IActionResult> Index() { List <Electronic> electronics = await ElectronicsDb.GetElectronicsAsync(_context); return(View(electronics)); }
public async Task <IActionResult> Categories(string category) { List <Electronic> electronics = await ElectronicsDb.GetCategoryElectronicsAsync(_context, category); return(View(electronics)); }
public async Task <IActionResult> SearchResults(string search) { List <Electronic> electronics = await ElectronicsDb.GetSearchElectronicsAsync(_context, search); return(View(electronics)); }