public async Task <IActionResult> Edit(int id, [Bind("Id,ProductBrand_Id,ProductType_Id,Slug_Id,Admin_Id,Name,Description,Price,Saleoff,Thumbnail,Instore,Stars,BuyPoints,Views,Orders,DateCreate,DateModify")] Product product) { if (id != product.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(product); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProductExists(product.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction("ProductsOverview", "Admin")); } ViewData["Admin_Id"] = new SelectList(_context.Admins, "Id", "Email", product.Admin_Id); ViewData["ProductBrand_Id"] = new SelectList(_context.ProductBrands, "Id", "Name", product.ProductBrand_Id); ViewData["ProductType_Id"] = new SelectList(_context.ProductTypes, "Id", "Type", product.ProductType_Id); ViewData["Slug_Id"] = new SelectList(_context.Slugs, "Id", "Url", product.Slug_Id); return(View(product)); }
public async Task <IActionResult> Create([Bind("Id,Admin_Id,Type,DateCreate,DateModify")] ProductType productType) { if (ModelState.IsValid) { _context.Add(productType); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["Admin_Id"] = new SelectList(_context.Admins, "Id", "Email", productType.Admin_Id); return(View(productType)); }
public async Task <IActionResult> Create([Bind("Id,Admin_Id,Name,DateCreate,DateModify")] ProductBrand productBrand) { if (ModelState.IsValid) { _context.Add(productBrand); await _context.SaveChangesAsync(); return(RedirectToAction("ProductBrandsOverview", "Admin")); } ViewData["Admin_Id"] = new SelectList(_context.Admins, "Id", "Email", productBrand.Admin_Id); return(View(productBrand)); }
public async Task <IActionResult> DeleteConfirmed(int id) { var user = await _context.Users.FindAsync(id); _context.Users.Remove(user); await _context.SaveChangesAsync(); return(RedirectToAction("UsersOverview", "Admin")); }